You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
In CII's chapter 9, Set_union(s,NULL) clones a set, but the cloned set's size
is smaller.
Here is test code:
Set_T s,t;
s = Set_new(1024,NULL,NULL);
t = Set_union(s,NULL);
printf("s:%d, t:%d\n", s->size,t->size);
output is:
s:1021, t:509
The problem seems related to Set_new's implementation:
static int primes[] = { 509, 509, 1021, 2053, 4093,
8191, 16381, 32771, 65521, INT_MAX };
assert(hint >= 0);
for (i = 1; primes[i] < hint; i++)
;
When giving it a hint, it searches the primes table and use the greatest one less than hint.
If the hint happens to be the number in primes, a much less value will be used.
What is the expected output? What do you see instead?
When clone a set, it's member size should be the same.
What version of the product are you using? On what operating system?
N/A
Please provide any additional information below.
N/A
Original issue reported on code.google.com by ligong...@gmail.com on 27 Jun 2012 at 12:46
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
ligong...@gmail.com
on 27 Jun 2012 at 12:46The text was updated successfully, but these errors were encountered: