Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::VectorSet< Value, Container > Struct Template Reference

A set built on an unsorted Vector, ensuring no item duplication. More...

#include <VectorSet.h>

Public Member Functions

auto size () const
 Return size of the set. More...
 
Value * begin ()
 
const Value * begin () const
 
Value * end ()
 
const Value * end () const
 
template<typename ComparableToValue >
bool contains (const ComparableToValue &value)
 Check if the given Value exists in the VectorSet. More...
 
bool insert (const Value &value)
 Inserts a value in the VectorSet (if it doesn't already exists) More...
 
template<typename ComparableToValue >
bool remove (const ComparableToValue &value)
 Removes a value from the VectorSet (if it exists) More...
 

Public Attributes

Container items
 

Detailed Description

template<typename Value, typename Container = SC::Vector<Value>>
struct SC::VectorSet< Value, Container >

A set built on an unsorted Vector, ensuring no item duplication.

Template Parameters
ValueThe contained value
ContainerThe underlying container used
VectorSet<String> setOfStrings;
SC_TEST_EXPECT(setOfStrings.insert("123"));
SC_TEST_EXPECT(setOfStrings.insert("123"));
SC_TEST_EXPECT(setOfStrings.contains("123"));
SC_TEST_EXPECT(setOfStrings.insert("456"));
SC_TEST_EXPECT(setOfStrings.contains("123"));
SC_TEST_EXPECT(setOfStrings.contains("456"));
SC_TEST_EXPECT(setOfStrings.size() == 2);
SC_TEST_EXPECT(setOfStrings.remove("123"));
SC_TEST_EXPECT(setOfStrings.size() == 1);
SC_TEST_EXPECT(setOfStrings.contains("456"));
SC_TEST_EXPECT(not setOfStrings.contains("123"));
for (auto& item : setOfStrings)
{
SC_TEST_EXPECT(item == "456");
}
#define SC_TEST_EXPECT(e)
Records a test expectation (eventually aborting or breaking o n failed test)
Definition: Testing.h:116

Member Function Documentation

◆ contains()

template<typename Value , typename Container = SC::Vector<Value>>
template<typename ComparableToValue >
bool SC::VectorSet< Value, Container >::contains ( const ComparableToValue &  value)
inline

Check if the given Value exists in the VectorSet.

◆ insert()

template<typename Value , typename Container = SC::Vector<Value>>
bool SC::VectorSet< Value, Container >::insert ( const Value &  value)
inline

Inserts a value in the VectorSet (if it doesn't already exists)

◆ remove()

template<typename Value , typename Container = SC::Vector<Value>>
template<typename ComparableToValue >
bool SC::VectorSet< Value, Container >::remove ( const ComparableToValue &  value)
inline

Removes a value from the VectorSet (if it exists)

◆ size()

template<typename Value , typename Container = SC::Vector<Value>>
auto SC::VectorSet< Value, Container >::size ( ) const
inline

Return size of the set.


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