PIP 5.5.3
Platform-Independent Primitives
Public Member Functions | Related Functions | List of all members
PISet< T > Class Template Reference

Set of any type. More...

#include <piset.h>

Inheritance diagram for PISet< T >:
Inheritance graph
[legend]

Public Member Functions

 PISet ()
 Contructs an empty set.
 
 PISet (const T &value)
 Contructs set with one element "value".
 
 PISet (const T &v0, const T &v1)
 Contructs set with elements "v0" and "v1".
 
 PISet (const T &v0, const T &v1, const T &v2)
 Contructs set with elements "v0", "v1" and "v2".
 
 PISet (const T &v0, const T &v1, const T &v2, const T &v3)
 Contructs set with elements "v0", "v1", "v2" and "v3".
 
 PISet (const PIVector< T > &values)
 Contructs set from vector of elements.
 
 PISet (const PIDeque< T > &values)
 Contructs set from deque of elements.
 
bool contains (const T &t) const
 Tests if element key exists in the set.
 
bool operator[] (const T &t) const
 Returns if element "t" exists in this set.
 
PISet< T > & remove (const T &t)
 Returns if element "t" exists in this set.
 
PISet< T > & unite (const PISet< T > &v)
 Unite set with "v".
 
PISet< T > & subtract (const PISet< T > &v)
 Subtract set with "v".
 
PISet< T > & intersect (const PISet< T > &v)
 Intersect set with "v".
 
PISet< T > & operator+= (const PISet< T > &v)
 Unite set with "v".
 
PISet< T > & operator|= (const PISet< T > &v)
 Unite set with "v".
 
PISet< T > & operator-= (const PISet< T > &v)
 Subtract set with "v".
 
PISet< T > & operator&= (const PISet< T > &v)
 Intersect set with "v".
 
PIVector< T > toVector () const
 Returns content of set as PIVector.
 
PIDeque< T > toDeque () const
 Returns content of set as PIDeque.
 
- Public Member Functions inherited from PIMap< T, uchar >
PIMap< T, uchar > & operator<< (const PIMap< T, uchar > &other)
 Inserts all elements in array other to this array with overwrite.
 
 PIMap ()
 Constructs an empty map.
 
 PIMap (const PIMap< T, uchar > &other)
 Copy constructor.
 
 PIMap (PIMap< T, uchar > &&other)
 Move constructor.
 
 PIMap (std::initializer_list< std::pair< T, uchar > > init_list)
 Contructs map from C++11 initializer list. More...
 
PIMap< T, uchar > & operator= (const PIMap< T, uchar > &other)
 Assign operator.
 
PIMap< T, uchar > & operator= (PIMap< T, uchar > &&other)
 Assign move operator.
 
iterator begin ()
 Iterator to the first element.
 
iterator end ()
 Iterator to the element following the last element.
 
reverse_iterator rbegin ()
 Returns a reverse iterator to the first element of the reversed array.
 
reverse_iterator rend ()
 Returns a reverse iterator to the element. following the last element of the reversed array.
 
size_t size () const
 Number of elements in the container. More...
 
int size_s () const
 Number of elements in the container as signed value. More...
 
size_t length () const
 Same as size(). More...
 
bool isEmpty () const
 Checks if the container has no elements. More...
 
bool isNotEmpty () const
 Checks if the container has elements. More...
 
uchar & operator[] (const T &key)
 Full access to element key key. More...
 
const uchar & at (const T &key) const
 Read only access to element by key. More...
 
uchar take (const T &key, const uchar &default_=uchar())
 Remove element with key key from the array and return it.
 
bool operator== (const PIMap< T, uchar > &m) const
 Compare operator with array m.
 
bool operator!= (const PIMap< T, uchar > &m) const
 Compare operator with array m.
 
bool contains (const T &key) const
 Tests if element with key key exists in the array.
 
bool containsValue (const uchar &value) const
 Tests if element with value value exists in the array.
 
PIMap< T, uchar > & reserve (size_t new_size)
 Attempts to allocate memory for at least new_size elements.
 
PIMap< T, uchar > & remove (const T &key)
 Remove element with key key from the array.
 
PIMap< T, uchar > & removeWhere (std::function< bool(const T &key, const uchar &value)> test)
 Remove all elements in the array passes the test implemented by the provided function test.
 
PIMap< T, uchar > & erase (const T &key)
 Same as remove().
 
PIMap< T, uchar > & clear ()
 Clear array, remove all elements. More...
 
void swap (PIMap< T, uchar > &other)
 Swaps array v other with this array. More...
 
PIMap< T, uchar > & insert (const T &key, const uchar &value)
 Inserts value value with key key in the array. More...
 
PIMap< T, uchar > & insert (const PIPair< T, uchar > &pair)
 Inserts value pair in the array. More...
 
uchar value (const T &key, const uchar &default_=uchar()) const
 Returns the value of the element by the key key or default_ if there is no such element.
 
PIVector< uchar > values () const
 Returns an array of values of all elements.
 
key (const uchar &value, const T &default_=T()) const
 Returns the key of the first element whose value matches value or default_ if there is no such element.
 
PIVector< T > keys () const
 Returns an array of keys of all elements.
 
void forEach (std::function< void(const T &key, const uchar &value)> f) const
 Execute function void f(const Key & key, const T & value) for every element in array.
 
PIMap< Key2, T2 > map (std::function< PIPair< Key2, T2 >(const T &key, const uchar &value)> f) const
 Сreates a new map PIMap<Key2, T2> populated with the results of calling a provided function PIPair<Key2, T2> f(const Key & key, const T & value) on every element in the calling array.
 
PIVector< ST > map (std::function< ST(const T &key, const uchar &value)> f) const
 Сreates a new array PIVector<ST> populated with the results of calling a provided function ST f(const Key & key, const T & value) on every element in the calling array.
 
PIMap< T, uchar > filter (std::function< bool(const T &key, const uchar &value)> test) const
 Returns a new array with all elements that pass the test implemented by the provided function bool test(const Key & key, const T & value).
 

Related Functions

(Note that these are not member functions.)

template<typename T >
PISet< T > operator+ (const PISet< T > &v0, const PISet< T > &v1)
 Returns unite of two sets.
 
template<typename T >
PISet< T > operator- (const PISet< T > &v0, const PISet< T > &v1)
 Returns subtraction of two sets.
 
template<typename T >
PISet< T > operator| (const PISet< T > &v0, const PISet< T > &v1)
 Returns unite of two sets.
 
template<typename T >
PISet< T > operator& (const PISet< T > &v0, const PISet< T > &v1)
 Returns intersetion of two sets.
 

Detailed Description

template<typename T>
class PISet< T >

Set of any type.

This class used to store collection of unique elements of any type. You can only add values to set with operator<< or with function insert(). You can discover if value already in set with operator[] or with function find(). These function has logarithmic complexity.