... | ... |
@@ -712,49 +712,49 @@ |
712 | 712 |
} |
713 | 713 |
|
714 | 714 |
/// \brief Inserts the given element into the given component. |
715 | 715 |
/// |
716 | 716 |
/// This methods inserts the element \e item a into the \e cls class. |
717 | 717 |
void insert(const Item& item, int cls) { |
718 | 718 |
int idx = newItem(); |
719 | 719 |
int rdx = classes[cls].firstItem; |
720 | 720 |
items[idx].item = item; |
721 | 721 |
items[idx].cls = cls; |
722 | 722 |
|
723 | 723 |
items[idx].prev = rdx; |
724 | 724 |
items[idx].next = items[rdx].next; |
725 | 725 |
items[items[rdx].next].prev = idx; |
726 | 726 |
items[rdx].next = idx; |
727 | 727 |
|
728 | 728 |
index.set(item, idx); |
729 | 729 |
} |
730 | 730 |
|
731 | 731 |
/// \brief Clears the union-find data structure |
732 | 732 |
/// |
733 | 733 |
/// Erase each item from the data structure. |
734 | 734 |
void clear() { |
735 | 735 |
items.clear(); |
736 |
classes.clear; |
|
736 |
classes.clear(); |
|
737 | 737 |
firstClass = firstFreeClass = firstFreeItem = -1; |
738 | 738 |
} |
739 | 739 |
|
740 | 740 |
/// \brief Gives back the class of the \e item. |
741 | 741 |
/// |
742 | 742 |
/// Gives back the class of the \e item. |
743 | 743 |
int find(const Item &item) const { |
744 | 744 |
return items[index[item]].cls; |
745 | 745 |
} |
746 | 746 |
|
747 | 747 |
/// \brief Gives back a representant item of the component. |
748 | 748 |
/// |
749 | 749 |
/// Gives back a representant item of the component. |
750 | 750 |
Item item(int cls) const { |
751 | 751 |
return items[classes[cls].firstItem].item; |
752 | 752 |
} |
753 | 753 |
|
754 | 754 |
/// \brief Removes the given element from the structure. |
755 | 755 |
/// |
756 | 756 |
/// Removes the element from its component and if the component becomes |
757 | 757 |
/// empty then removes that component from the component list. |
758 | 758 |
/// |
759 | 759 |
/// \warning It is an error to remove an element which is not in |
760 | 760 |
/// the structure. |
0 comments (0 inline)