static void test_stSortedSet(CuTest* testCase) { sonLibSortedSetTestSetup(); int32_t i; CuAssertIntEquals(testCase, 0, stSortedSet_size(sortedSet)); for(i=0; i<size; i++) { stSortedSet_insert(sortedSet, stIntTuple_construct(1, input[i])); } CuAssertIntEquals(testCase, sortedSize, stSortedSet_size(sortedSet)); CuAssertIntEquals(testCase, sortedInput[0], stIntTuple_getPosition(stSortedSet_getFirst(sortedSet), 0)); CuAssertIntEquals(testCase, sortedInput[sortedSize-1], stIntTuple_getPosition(stSortedSet_getLast(sortedSet), 0)); for(i=0; i<sortedSize; i++) { CuAssertIntEquals(testCase, sortedSize-i, stSortedSet_size(sortedSet)); stIntTuple *tuple = stIntTuple_construct(1, sortedInput[i]); CuAssertTrue(testCase, stIntTuple_getPosition(stSortedSet_search(sortedSet, tuple), 0) == sortedInput[i]); stSortedSet_remove(sortedSet, tuple); CuAssertTrue(testCase, stSortedSet_search(sortedSet, tuple) == NULL); stIntTuple_destruct(tuple); } sonLibSortedSetTestTeardown(); }
/* * Adds a prime less than (or equals) constraint to the list of prime constraints, removing any redundant constraints in the process. * The or equals is specified by making the lessThanOrEquals argument non-zero. */ void addConstraint_lessThan(stPosetAlignment *posetAlignment, int64_t sequence1, int64_t position1, int64_t sequence2, int64_t position2, int64_t lessThanOrEquals) { stSortedSet *constraintList = getConstraintList(posetAlignment, sequence1, sequence2); assert(position1 != INT64_MAX); assert(position2 != INT64_MAX); stIntTuple *constraint1 = stIntTuple_construct3( position1, position2, lessThanOrEquals); stIntTuple *constraint2; while((constraint2 = stSortedSet_searchLessThanOrEqual(constraintList, constraint1)) != NULL) { assert(stIntTuple_get(constraint2, 0) <= position1); if(stIntTuple_get(constraint2, 1) >= position2) { if(stIntTuple_get(constraint2, 1) == position2) { //Check we are not removing an equivalent or more severe constraint. assert((!lessThanOrEquals && stIntTuple_get(constraint2, 2)) || stIntTuple_get(constraint2, 0) < position1); } stSortedSet_remove(constraintList, constraint2); stIntTuple_destruct(constraint2); } else { assert(stIntTuple_get(constraint2, 0) < position1); //Check the constraint does not overshadow our proposed constraint. break; } } stSortedSet_insert(constraintList, constraint1); }
void eventTree_removeEvent(EventTree *eventTree, Event *event) { stSortedSet_remove(eventTree->events, event); }
void flower_removeFace(Flower *flower, Face *face) { assert(stSortedSet_search(flower->faces, face) != NULL); stSortedSet_remove(flower->faces, face); }
void flower_removeGroup(Flower *flower, Group *group) { assert(stSortedSet_search(flower->groups, group) != NULL); stSortedSet_remove(flower->groups, group); }
void flower_removeChain(Flower *flower, Chain *chain) { assert(stSortedSet_search(flower->chains, chain) != NULL); stSortedSet_remove(flower->chains, chain); }
void flower_removeBlock(Flower *flower, Block *block) { block = block_getPositiveOrientation(block); assert(stSortedSet_search(flower->blocks, block) != NULL); stSortedSet_remove(flower->blocks, block); }
void flower_removeSegment(Flower *flower, Segment *segment) { segment = segment_getPositiveOrientation(segment); assert(stSortedSet_search(flower->segments, segment) != NULL); stSortedSet_remove(flower->segments, segment); }
void flower_removeEnd(Flower *flower, End *end) { end = end_getPositiveOrientation(end); assert(stSortedSet_search(flower->ends, end) != NULL); stSortedSet_remove(flower->ends, end); }
void flower_removeCap(Flower *flower, Cap *cap) { cap = cap_getPositiveOrientation(cap); assert(stSortedSet_search(flower->caps, cap) != NULL); stSortedSet_remove(flower->caps, cap); }
void flower_removeSequence(Flower *flower, Sequence *sequence) { assert(stSortedSet_search(flower->sequences, sequence) != NULL); stSortedSet_remove(flower->sequences, sequence); }
void cactusDisk_removeMetaSequence(CactusDisk *cactusDisk, MetaSequence *metaSequence) { assert(stSortedSet_search(cactusDisk->metaSequences, metaSequence) != NULL); stSortedSet_remove(cactusDisk->metaSequences, metaSequence); }