sincerely
Singaporean
If you have not done so, read this full tutorial on how to use SGEXTN to build an application.
(no source file, everything inside header)
template ‹typename T, typename Comparator› class SGLSet;
part of SGEXTN module SG_Containers
set for any type of data
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGLSet.h›
CMake target for BuildLah: SGEXTN::SG_Containers
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
SGLSet();
[[nodiscard]] SGLSet::Iterator begin();
[[nodiscard]] SGLSet::ConstIterator constBegin() const;
[[nodiscard]] SGLSet::ConstIterator constEnd() const;
[[nodiscard]] SGLSet::ConstIterator constIteratorAt(int n) const;
[[nodiscard]] bool contains(const T& x) const;
[[nodiscard]] int count(const T& x) const;
[[nodiscard]] const T& elementAt(int n) const;
[[nodiscard]] SGLSet::Iterator end();
bool erase(SGLSet::Iterator& i);
bool erase(const T& x);
[[nodiscard]] SGLSet::ConstIterator find(const T& x) const;
[[nodiscard]] SGLSet::Iterator find(const T& x);
[[nodiscard]] int indexOf(SGLSet::ConstIterator i) const;
[[nodiscard]] int indexOf(const T& x) const;
[[nodiscard]] int indexOf(SGLSet::Iterator i) const;
bool insert(const T& x);
[[nodiscard]] SGLSet::Iterator iteratorAt(int n);
[[nodiscard]] int length() const;
[[nodiscard]] SGLSet::Iterator lowerBound(const T& x);
[[nodiscard]] SGLSet::ConstIterator lowerBound(const T& x) const;
[[nodiscard]] SGLSet::ConstIterator upperBound(const T& x) const;
[[nodiscard]] SGLSet::Iterator upperBound(const T& x);
SGLSet provides a template based set that can be used with any data type. Use SGLUnorderedSet if order does not matter. This is a template based class with no separate source file. This class is a SGEXTN container. Copy constructor, copy assignment, move constructor, move assignment, and destructor work as expected. A deep copy is performed whenever this class is copied, and the new instance will not be linked to the old instance in any way. It is assumed that the contents placed into this SGEXTN container can be copied and moved. This means that their copy constructor copy assignment, move constructor, move assignment, and destructor work as expected. If this is not the case or if you want the container to store references or constant references, store pointers instead.
SGLSet maintains a AVL tree, which is a type of self balancing binary search tree. Most other C++ libraries use a red black tree instead. This makes SGLSet slightly faster than other libraries for accessing elements but slightly slower for modifying the data structure.
Creates an empty SGLSet.
Returns a iterator to the first element in the SGLSet.
SGLSet iterators behave circularly. This is equivalent to running operator++ on SGLSet::end.
SGLSet::Iterator allows modifying the SGLSet through it. If modification is not needed, use SGLSet::ConstIterator instead. The SGLSet::ConstIterator equivalent to this function is SGLSet::constBegin.
If the SGLSet is empty, this is the same as SGLSet::end.
Returns a constant iterator to the first element in the SGLSet.
SGLSet iterators behave circularly. This is equivalent to running operator++ on SGLSet::constEnd.
If the SGLSet is empty, this is the same as SGLSet::constEnd.
Returns a null constant iterator associated to this SGLSet.
SGLSet iterators behave circularly. This is equivalent to running operator-- on SGLSet::constBegin.
Attempting to access the element that this iterator points to will crash.
Returns the constant iterator pointing towards the element at index n in the SGLSet.
If n is out of bounds, SGLSet::constEnd is returned.
Returns if the SGLSet contains x.
Returns the number of copies of x in the SGLSet, this is either 0 or 1.
This has identical functionality to SGLSet::contains, it is included for API consistency.
Returns the element at index n in the SGLSet.
If n is out of bounds, this is undefined behaviour.
Returns a null iterator associated to this SGLSet.
SGLSet iterators behave circularly. This is equivalent to running operator-- on SGLSet::begin.
SGLSet::Iterator allows modifying the SGLSet through it. If modification is not needed, use SGLSet::ConstIterator instead. The SGLSet::ConstIterator equivalent to this function is SGLSet::constEnd.
Attempting to access the element that this iterator points to will crash.
Removes the element associated with i from the SGLSet.
After the removal, i which is passed as a reference, is decremented. This means that you do not have to do any special handling for removed elements when iterating over a SGLSet.
This returns false if i is SGLSet::end and true otherwise.
Do not write any special logic to modify iterators while removing elements from a SGLSet in a loop, SGLSet::eraseSGLSet::erase handles this for you automatically.
Removes x from the SGLSet.
If the SGLSet does not contain x, this function will return false, otherwise this returns true.
Returns the constant iterator pointing to element x.
SGLSet::constEnd is returned if x is not in the SGLSet.
Returns the iterator pointing to element x.
SGLSet::end is returned if x is not in the SGLSet.
Returns the index of the element in the SGLSet that i points to.
-1 is returned if i is SGLSet::constEnd.
The index may change if elements are inserted into or removed from SGLSet to keep the SGLSet always sorted.
Returns the index of x in the SGLSet.
-1 is returned if x is not in the SGLSet.
The index may change if elements are inserted into or removed from SGLSet to keep the SGLSet always sorted.
Returns the index of the element in the SGLSet that i points to.
-1 is returned if i is SGLSet::end.
The index may change if elements are inserted into or removed from SGLSet to keep the SGLSet always sorted.
Inserts x into the SGLSet.
If the SGLSet already contains x, this function will return false, otherwise this returns true.
Returns the iterator pointing towards the element at index n in the SGLSet.
SGLSet::Iterator allows modifying the SGLSet through it. If modification is not needed, use SGLSet::ConstIterator instead. The SGLSet::ConstIterator equivalent to this function is SGLSet::constIteratorAt.
If n is out of bounds, SGLSet::end is returned.
Returns the length of the SGLSet, this is the number of elements stored inside it.
Returns a iterator to the first element in the SGLSet more than or equal to x.
SGLSet::end is returned if no such iterator exists.
Returns a constant iterator to the first element in the SGLSet more than or equal to x.
SGLSet::constEnd is returned if no such iterator exists.
Returns a constant iterator to the first element in the SGLSet strictly more than x.
SGLSet::constEnd is returned if no such iterator exists.
Returns a iterator to the first element in the SGLSet strictly more than x.
SGLSet::end is returned if no such iterator exists.
©2025 05524F.sg (Singapore)