40 Set::operator const SparseSet*() const { assert(0); return NULL; } */
41 const SparseSet *Set::asSparseSet() const { assert(0); return NULL; }
42 class VectorSet;
43 /* Removed for MCC BUG
44 Set::operator const VectorSet*() const { assert(0); return NULL; } */
45 const VectorSet *Set::asVectorSet() const { assert(0); return NULL; }
46 class ListSet;
47 /* Removed for MCC BUG
48 Set::operator const ListSet*() const { assert(0); return NULL; } */
49 const ListSet *Set::asListSet() const { assert(0); return NULL; }
50 class CoSet;
51 /* Removed for MCC BUG
52 Set::operator const CoSet*() const { assert(0); return NULL; } */
53 const CoSet *Set::asCoSet() const { assert(0); return NULL; }
54
55 //------------------------------setstr-----------------------------------------
56 // Create a string with a printable representation of a set.
57 // The caller must deallocate the string.
58 char *Set::setstr() const
59 {
60 if( !this ) return os::strdup("{no set}");
61 Set &set = clone(); // Virtually copy the basic set.
62 set.Sort(); // Sort elements for in-order retrieval
63
64 uint len = 128; // Total string space
65 char *buf = NEW_C_HEAP_ARRAY(char,len, mtCompiler);// Some initial string space
66
67 register char *s = buf; // Current working string pointer
68 *s++ = '{';
69 *s = '\0';
70
71 // For all elements of the Set
72 uint hi = (uint)-2, lo = (uint)-2;
73 for( SetI i(&set); i.test(); ++i ) {
74 if( hi+1 == i.elem ) { // Moving sequentially thru range?
75 hi = i.elem; // Yes, just update hi end of range
76 } else { // Else range ended
77 if( buf+len-s < 25 ) { // Generous trailing space for upcoming numbers
78 int offset = (int)(s-buf);// Not enuf space; compute offset into buffer
79 len <<= 1; // Double string size
80 buf = REALLOC_C_HEAP_ARRAY(char,buf,len, mtCompiler); // Reallocate doubled size
|
40 Set::operator const SparseSet*() const { assert(0); return NULL; } */
41 const SparseSet *Set::asSparseSet() const { assert(0); return NULL; }
42 class VectorSet;
43 /* Removed for MCC BUG
44 Set::operator const VectorSet*() const { assert(0); return NULL; } */
45 const VectorSet *Set::asVectorSet() const { assert(0); return NULL; }
46 class ListSet;
47 /* Removed for MCC BUG
48 Set::operator const ListSet*() const { assert(0); return NULL; } */
49 const ListSet *Set::asListSet() const { assert(0); return NULL; }
50 class CoSet;
51 /* Removed for MCC BUG
52 Set::operator const CoSet*() const { assert(0); return NULL; } */
53 const CoSet *Set::asCoSet() const { assert(0); return NULL; }
54
55 //------------------------------setstr-----------------------------------------
56 // Create a string with a printable representation of a set.
57 // The caller must deallocate the string.
58 char *Set::setstr() const
59 {
60 if( this == NULL ) return os::strdup("{no set}");
61 Set &set = clone(); // Virtually copy the basic set.
62 set.Sort(); // Sort elements for in-order retrieval
63
64 uint len = 128; // Total string space
65 char *buf = NEW_C_HEAP_ARRAY(char,len, mtCompiler);// Some initial string space
66
67 register char *s = buf; // Current working string pointer
68 *s++ = '{';
69 *s = '\0';
70
71 // For all elements of the Set
72 uint hi = (uint)-2, lo = (uint)-2;
73 for( SetI i(&set); i.test(); ++i ) {
74 if( hi+1 == i.elem ) { // Moving sequentially thru range?
75 hi = i.elem; // Yes, just update hi end of range
76 } else { // Else range ended
77 if( buf+len-s < 25 ) { // Generous trailing space for upcoming numbers
78 int offset = (int)(s-buf);// Not enuf space; compute offset into buffer
79 len <<= 1; // Double string size
80 buf = REALLOC_C_HEAP_ARRAY(char,buf,len, mtCompiler); // Reallocate doubled size
|