Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:33:16+00:00 2026-06-13T16:33:16+00:00

I have a function, it is called inside a loop, it can generate a

  • 0

I have a function, it is called inside a loop, it can generate a set of integer for each loop, for example:

result for loop 1: {1 1 1 2}
result for loop 2: {1 1 1 3}
result for loop 3: {2 1 1 3}
result for loop 4: {3 1 3 2}

and this function may generate duplication result, for example, result 2 and result 3 is the same. I need to put these results inside a data structure, but can not put the duplication, if the result 2 is the same as result 3, only one of them should be kept, how to achieve it in C?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:33:18+00:00Added an answer on June 13, 2026 at 4:33 pm

    If the range of items is small enough, you can use bitmaps as a mean of enumeration. E.g. if you want to represent set of integers in range from 1 to 32, all that is required is a 32-bit integer used as a bitmap:

    00000001 00000001 00000000 00000000    - for set {8,16}
           ^        ^
           8        16
    

    etc.

    If the range is larger, use array of bytes, where each bit represents whether value at this position is present in set:

    #define MAXVAL 1024
    
    typedef unsigned char bitmap_t[];
    byte bitmap[1 + MAXVAL / CHAR_BIT] = { 0 };
    // CHAR_BIT is defined in limit.h and is equal to count of bits in a byte
    
    void insert(bitmap_t bitmap, unsigned val) {
      assert(val < MAXVAL);
      bitmap[val / CHAR_BIT] |= (1 << (val % CHAR_BIT);
    }
    
    int is_present(bitmap_t bitmap, unsigned val) {
      assert(val < MAXVAL);
      return bitmap[ val / CHAR_BIT ] & (1 << (val % CHAR_BIT));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that is often called inside of other functions, and I'd
I have this function called ProperCase that takes a string, then converts the first
Now I'm sure this is super easy, I have a function called remove_deposit which
I have a function called call facebook. call_facebook(284328420994); call_facebook(197214710347172); It runs severaltimes It makes
I have a function called PreProcessSource, which allocates a boost::wave::context and does some preprocessing;
I have a function called Colorbox (jQuery plugin) that takes a number of parameters
I am using jQuery(Latest release) and have a function called calculate() which gets called
I have a prototype representing a particual IFrame. That prototype have a function called
I'm using linux. I have a function called like: PlayBackgroundIntroMusic((char *)IntroMusic); The functions is:
I have a Java function called testForNull public static void testForNull(Object obj) { if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.