PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::common::BruteSet< T, kCapacity > Class Template Reference

Fixed-size brute-force set implementation. More...

#include <BruteSet.h>

Public Member Functions

 BruteSet ()
 Construct a new BruteSet object.
 
T * begin ()
 Begin iterator.
 
T * end ()
 End iterator.
 
T const * begin () const
 Const begin iterator.
 
T const * end () const
 Const end iterator.
 
bool Insert (T const &value)
 Insert an element into the set.
 
bool Contains (T const &value) const
 Check if the set contains an element.
 
bool Remove (T const &value)
 Remove an element from the set.
 
int Size () const
 Get the size of the set.
 
bool IsFull () const
 Check if the set is full.
 
bool IsEmpty () const
 Check if the set is empty.
 
void Clear ()
 Clear the set.
 

Detailed Description

template<class T, auto kCapacity = 32>
class pbat::common::BruteSet< T, kCapacity >

Fixed-size brute-force set implementation.

Template Parameters
TType of the elements in the set
Parameters
kCapacityMaximum number of elements in the set

This set is suitable for small sets where the maximum number of elements is known at compile time. It uses a simple array to store the elements and provides basic operations such as insertion, removal, and membership testing.

Member Function Documentation

◆ begin() [1/2]

template<class T, auto kCapacity = 32>
T * pbat::common::BruteSet< T, kCapacity >::begin ( )
inline

Begin iterator.

Returns
Pointer to the beginning of the set

◆ begin() [2/2]

template<class T, auto kCapacity = 32>
T const * pbat::common::BruteSet< T, kCapacity >::begin ( ) const
inline

Const begin iterator.

Returns
Pointer to the beginning of the set

◆ Clear()

template<class T, auto kCapacity = 32>
void pbat::common::BruteSet< T, kCapacity >::Clear ( )
inline

Clear the set.

Removes all elements from the set, resetting its size to zero.

◆ Contains()

template<class T, auto kCapacity = 32>
bool pbat::common::BruteSet< T, kCapacity >::Contains ( T const & value) const
inline

Check if the set contains an element.

Parameters
valueElement to check
Returns
True if the element is in the set, false otherwise

◆ end() [1/2]

template<class T, auto kCapacity = 32>
T * pbat::common::BruteSet< T, kCapacity >::end ( )
inline

End iterator.

Returns
Pointer to the end of the set

◆ end() [2/2]

template<class T, auto kCapacity = 32>
T const * pbat::common::BruteSet< T, kCapacity >::end ( ) const
inline

Const end iterator.

Returns
Pointer to the end of the set

◆ Insert()

template<class T, auto kCapacity = 32>
bool pbat::common::BruteSet< T, kCapacity >::Insert ( T const & value)
inline

Insert an element into the set.

Parameters
valueElement to insert
Returns
True if the element was inserted, false if it was already present
Note
Does not check overflow, so ensure that the set does not exceed kCapacity before inserting.

◆ IsEmpty()

template<class T, auto kCapacity = 32>
bool pbat::common::BruteSet< T, kCapacity >::IsEmpty ( ) const
inline

Check if the set is empty.

Returns
True if the set is empty, false otherwise

◆ IsFull()

template<class T, auto kCapacity = 32>
bool pbat::common::BruteSet< T, kCapacity >::IsFull ( ) const
inline

Check if the set is full.

Returns
True if the set is full, false otherwise

◆ Remove()

template<class T, auto kCapacity = 32>
bool pbat::common::BruteSet< T, kCapacity >::Remove ( T const & value)
inline

Remove an element from the set.

Parameters
valueElement to remove
Returns
True if the element was removed, false if it was not present

◆ Size()

template<class T, auto kCapacity = 32>
int pbat::common::BruteSet< T, kCapacity >::Size ( ) const
inline

Get the size of the set.

Returns
Number of elements in the set

The documentation for this class was generated from the following file: