Tk Source Code

Diff
Login

Differences From Artifact [1d7e9c77]:

To Artifact [f6530cb9]:


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
83
84
85
86
87
88
89


90
91
92
93
94
95
96







-
-







	    return false;
	}
    }
    return true;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

unsigned
TkIntSetFindFirstInIntersection(
    const TkIntSet *set,
    const TkBitField *bf)
{
    unsigned size, i;

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
108
109
110
111
112
113
114


115
116
117
118
119
120
121







-
-







	    }
	}
    }

    return TK_SET_NPOS;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


TkIntSetType *
TkIntSetLowerBound(
    TkIntSetType *first,
    TkIntSetType *last,
    TkIntSetType value)
{
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
141
142
143
144
145
146
147


148
149
150
151
152
153
154







-
-







    set->refCount = 0;
    set->isSetFlag = true;
    DEBUG_ALLOC(tkIntSetCountNew++);
    return set;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

TkIntSet *
TkIntSetFromBits(
    const TkBitField *bf)
{
    unsigned size;
    TkIntSet *set;
    unsigned index = 0, i;
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
163
164
165
166
167
168
169


170
171
172
173
174
175
176







-
-







    for (i = TkBitFindFirst(bf); i != TK_BIT_NPOS; i = TkBitFindNext(bf, i)) {
	set->buf[index++] = i;
    }

    return set;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


void
TkIntSetDestroy(
    TkIntSet **setPtr)
{
    assert(setPtr);

309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
301
302
303
304
305
306
307


308
309
310
311
312
313
314







-
-







	}
    }

    return dst;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

TkIntSet *
TkIntSetJoinBits(
    TkIntSet *dst,
    const TkBitField *src)
{
    TkIntSet *set;

351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
341
342
343
344
345
346
347


348
349
350
351
352
353
354







-
-







    }

    set->refCount = 1;
    set->isSetFlag = true;
    return set;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


static TkIntSetType *
Join2(
    TkIntSetType *dst,
    const TkIntSetType *src, const TkIntSetType *srcEnd,
    const TkIntSetType *set1, const TkIntSetType *set1End,
    const TkIntSetType *set2, const TkIntSetType *set2End)
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
509
510
511
512
513
514
515


516
517
518
519
520
521
522







-
-







	}
    }

    return dst;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

TkIntSet *
TkIntSetIntersectBits(
    TkIntSet *dst,
    const TkBitField *src)
{
    TkIntSet *set;
    unsigned size;
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
548
549
550
551
552
553
554


555
556
557
558
559
560
561







-
-







    }

    set->refCount = 1;
    set->isSetFlag = true;
    return set;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


static TkIntSetType *
Remove(
    TkIntSetType *dst,
    const TkIntSetType *src, const TkIntSetType *srcEnd,
    const TkIntSetType *sub, const TkIntSetType *subEnd)
{
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
639
640
641
642
643
644
645


646
647
648
649
650
651
652







-
-







	dst += size;
    }

    return dst;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

TkIntSet *
TkIntSetRemoveBits(
    TkIntSet *dst,
    const TkBitField *src)
{
    TkIntSet *set;
    unsigned capacity1, capacity2;
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
675
676
677
678
679
680
681


682
683
684
685
686
687
688







-
-







    }

    set->refCount = 1;
    set->isSetFlag = true;
    return set;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


static TkIntSetType *
ComplementTo(
    TkIntSetType *dst,
    const TkIntSetType *sub, const TkIntSetType *subEnd,
    const TkIntSetType *src, const TkIntSetType *srcEnd)
{
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
753
754
755
756
757
758
759


760
761
762
763
764
765
766







-
-







	*dst++ = i;
    }

    return dst;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

TkIntSet *
TkIntSetComplementToBits(
    TkIntSet *dst,
    const TkBitField *src)
{
    TkIntSet *set;
    unsigned capacity1, capacity2;
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
789
790
791
792
793
794
795


796
797
798
799
800
801
802







-
-







    }

    set->refCount = 1;
    set->isSetFlag = true;
    return set;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


static TkIntSetType *
JoinComplementTo(
    TkIntSetType *dst,
    const TkIntSetType *src, const TkIntSetType *srcEnd,
    const TkIntSetType *set1, const TkIntSetType *set1End,
    const TkIntSetType *set2, const TkIntSetType *set2End)
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1179
1180
1181
1182
1183
1184
1185


1186
1187
1188
1189
1190
1191
1192







-
-







	}
    }

    return true;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

bool
TkIntSetIntersectionIsEqual(
    const TkIntSet *set1,
    const TkIntSet *set2,
    const TkBitField *del)
{
    const TkIntSetType *s1;
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1255
1256
1257
1258
1259
1260
1261


1262
1263
1264
1265
1266
1267
1268







-
-








    TkBitIntersect(cp, bf);
    test = TkIntSetIsEqualBits(set, cp);
    TkBitDestroy(&cp);
    return test;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


static TkIntSet *
Add(
    TkIntSet *set,
    TkIntSetType *pos,
    unsigned n)
{
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1435
1436
1437
1438
1439
1440
1441


1442
1443
1444
1445
1446
1447
1448







-
-







	DEBUG_ALLOC(tkIntSetCountDestroy++);
    }

    return newSet;
}


#if !TK_TEXT_DONT_USE_BITFIELDS

bool
TkIntSetIsEqualBits(
    const TkIntSet *set,
    const TkBitField *bf)
{
    unsigned sizeSet, sizeBf, i;

1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1522
1523
1524
1525
1526
1527
1528


1529
1530
1531
1532
1533
1534
1535







-
-







	    return false;
	}
    }

    return true;
}

#endif /* !TK_TEXT_DONT_USE_BITFIELDS */


#ifndef NDEBUG

# include <stdio.h>

void
TkIntSetPrint(