stdcol is cross-platfrom library for storing data in data structures. stdcol provides the interfaces, and implemented classes.
When you see (const) anywhere, that means that the declaration was declared as both const and non-const
struct index- Type Declarations
using int_type: The underlying integer type. use forconstexprs
- Members
int_type value: The underlying value of the index
- Constructors
index()index(const int_type& value)
- Methods
int_type& operator=(const int_type& value): Pass through to the underlying valueoperator (const) int_type&() (const): Pass through to the underlying value
- Type Declarations
struct findex : index- Constant Expressions
static constexpr const int_type not_found: The underlying int_type value that corresponds to a function returning the index of anything that does not exist.
- Constructors
findex()findex(const int_type& value)
- Methods
bool found() const: Equivalent to value != not_found
- Constant Expressions
template <typename key_t, typename value_t> struct key_value_pair- Members
key_t keyvalue_t value
- Members
template <typename value_t> struct enumeration- Members
findex indexvalue_t value
- Constructors
enumeration(stdcol::index index, value_t value)
- Methods
operator value_t() (const): Pass through to thevaluevoid operator=(const value_t& value): Pass through to thevalue
- Members
template <typename collectable_t> struct prioritized_element- Members
int priority:collectable_t item
- Constructors
prioritized_element()prioritized_element(int priority, collectable_t item)
- Members
template <typename T> std::initializer_listOnly defined on a platform with no STL (determined by stdcol_nostl macro), This is a general copy of STL's versiontemplate <typename T> linked_node- Type Declarations
using link = linked_node<T>*
- Members
T value
- Constructors
linked_node(): Default constructT valuetemplate <typename... args_t> linked_node(link previous, link next, args_t... args): ConstructsT valuewithargs..., and supplypreviousandnextlink
- Methods
(const) T operator&() (const)(const) T operator*() (const)link get_previous() constlink get_next() const
- Type Declarations
template <typename T> class binary_tree_node : public abstract_tree_node<T>- Type Declarations
using link = binary_tree_node<T>*using const_link = const binary_tree_node<T>*
- Constructors
binary_tree_node(): Default initializes valuebinary_tree_node(link) = delete: Deleted to disambiguate constructing defualt value with a parent nodetemplate <typename... args_t> binary_tree_node(link parent_node, args_t... args): Construct value withargs...
- Methods
(const) T& get_value() (const)link parent()collection<typename abstract_tree_node<T>::tree_link>& children()link& left()link& right()index height()long long balance_height()link rotate(rotations rotation): Rotates node and returns what replaces this node's positinlink balance_ancestors()
- Type Declarations
enum class rotationsleftrightleft_rightright_left
template <typename T> class tree_node : public abstract_tree_node<T>- Type Declarations
using node = abstract_tree_node<T>using link = tree_node<T>*
- Constructors
tree_node(): Default constructs valuetree_node(link parent_node) = delete: Deleted to disambiguate constructing defualt value with a parent nodetemplate <typename... args_t> tree_node(link parent_node, args_t... args): Construct value withargs...
- Methods
(const) T& get_value() (const)collection<typename abstract_tree_node<T>::tree_link>& children()linked<link>& links()link parent()
- Type Declarations
template <typename T> class graph_node- Type Declarations
using node = graph_node<T>using link = node*
- Constructors
template <typename... args_t> graph_node(args_t... args)
- Methods
linked<link>& get_edges() constoperator (const) T&() (const)bool add_edge(link other)
- Type Declarations
stdcol is built around it's interfaces.
template <typename collectable_t> class collection- Description: This abstract type is the underlying type for all of stdcol, it is a wrapper around 1-dimensional, 0-indexed collections.
- Type Declarations
using iterator_dereference_t: Whatoperator*()returns from the iterator used by acollectionusing iterator: The typebegin()andend()returns
- Abstract Methods
(const) collectable_t * const at(index index) (const): Returns a pointer to the element at the specified indexindex size() const: returns how many elements exist in the collection
- Methods
virtual (const) collectable_t& operator[](index index) (const): equivalent to *at(index), does not perform nullptr checkiterator begin(): Returns an iterator pointing to the first elementiterator end(): Returns an iterator pointing 1 past the last element
template <typename collectable_t> class dynamic_collection : collection<collectable_t>- Description: This abstract type derives from collection, but also wraps around collections that are of dynamic size, and capacity.
- Abstract Methods:
index capacity() const: How many elements could fit within the allocated blockbool reserve(index new_capacity): Changes the size of the allocated block to fit at leastnew_capacityamount of elements. Returns true if reservation is successfulbool resize(index new_size): Changes how many items are in the collection, not the same ascapacity(). More specifically, this should change whatsize()returns. Returnstrueis resize is successfulbool insert(index index, const collectable_t& item): Inserts theitemat the specified index, pushes the item currently at the index in front ofitem. Returnstrueif insertion is successfulbool remove(index index): Removes the item at the specified index. Returntrueif removal was successful
template <typename hashable_t, typename collectable_t> class dictionary- Description: This abstract type is the wrapper for all containers that use a
key_value_pair - Type Declarations
using kvp_t: The key-value pair type for the class and its implementorsusing bucket_t: The type that is a collection of key-value pairsusing buckets_t: The type that is a collection of bucket_t
- Abstract Methods
bool contains(const hashable_t& key) const: Returnstrueif any key in any bucket existsbool add(const hashable_t& key, const collectable_t& value): Adds the key-value pair to a bucket, returnstrueif the key-value pair was added successfullykvp_t* get(const hashable_t& key): Returns a pointer to the key-value pair with the specifiedkey, return nullptr if key does not existcollectable_t& get_add(const hashable_t& key): Returns the value of with the specifiedkey, adds if does not existbool remove(const hashable_t& key): Removes the specifiedkey, returnstrueif the item was successfully removedbool resize(index bucket_count): Resizes the amount of buckets, returntrueif bucket resize was successfulbuckets_t& buckets(): Returns the bucketsbucket_t& bucket(const hashable_t& key): Returns the bucket thekeywould be in according tohash()index hash(const hashable_t& key): Returns the hash value of thekey
- Methods
virtual collectable_t& operator[](const hashable_t& key): Equivalent to*get_add(key)virtual index size(): Returns the number of key-value pairsvirtual dynamic_array<hashable_t> keys(): Returns a collection of all the keysvirtual dynamic_array<hashable_t> values(): Returns a collection of all the valuesvirtual dynamic_array<hashable_t> key_values(): Returns a collection of all the key-value pairs
- Description: This abstract type is the wrapper for all containers that use a
template <typename T> class abstract_tree_node- Description: This abstract type is a wrapper around a tree node of any tree data structure
- Type Declarations
using tree_link: The type of a node pointer
- Abstract Methods
(const) T& get_value() (const): Returns the valuecollection<tree_link>& children(): Returns a collection of children nodestree_link parent(): Returns the parent node, returnnullptrif no parent exists
- Methods
(const) T* operator&() (const): Equivalent to&get_value()(const) T& operator*() (const): Equivalent toget_value()
template <typename T> class abstract_tree- Description: This abstract type is a wrapper around all tree data structures
- Type Declarations
using link: The type of a node pointerusing const_link: The type of a const node pointer
- Abstract Methods
(const_link) link root() (const): Returns the root node of the tree,nullptrif no root nodes exist
template <typename hashable_t> struct stdcol_hasher- This incomplete type should implement
index operator()(const hashable_t&) const, and should be a template specialization
- This incomplete type should implement
template <typename hashable_t> using hasher: The hasher type that data stdcol api uses to automatically search template specializations fortemplate <typename collectable_t> using initializer_list: The brace-enclosed init-list type
template <typename collectable_t, index::int_type static_size> array : public collection<collectable_t>- Description: 1-dimensional, static size, homogoneous collection
template <typename collectable_t> class dynamic_array : public dynamic_collection<collectable_t- Description: 1-dimensional, dynamic size, homogoneous collection
template <typename collectable_t> class set : public dynamic_collection<collectable_t>- Description: 1-dimensional encapsulator of dynamic_array with special insertion methods to keep unique items
template <typename collectable_t> class queue : public dynamic_array<collectable_t>- Description: dynamic_array with extra methods relating to FIFO queues
template <typename collectable_t> class priority_queue : dynamic_collection<prioritized_element<collectable_t>>- Description: dynamic_array encapsulator to
prioritized_elementqueues
- Description: dynamic_array encapsulator to
template <typename collectable_t> class stack : public dynamic_array<collectable_t>- Description: dynamic_array with extra methods relating to LIFO stacks
template <typename T> class linked : public dynamic_collection<T>- Description: linked list with support for non-default constructables
template <typename hashable_t, typename collectable_t, typename hasher_t = hasher<hashable_t>> class hash_table : public dictionary<hashable_t, collectable_t>- Description: Key-value pair data structure
template <typename T> class binary_tree : public abstract_tree<binary_tree_node<T>>- Description: Binary tree data structure
template <typename T> class avl_tree : public abstract_tree<binary_tree_node<T>>- Description: Binary tree encapsulator with special extra operations to ensure balanced trees
template <typename T> class directed_graph- Description: Directed graph data structure
stdcol also provides functions for manipulating collections
size(): Returns the size of a data structuretemplate <typename collectable_t> const index size(collection<collectable_t>& collection): Returns the size of the collectiontemplate <typename T, index::int_type ssize> constexpr cosnt index::int_type size(const T (&array)[ssize]): Returns the size of the c-style array
at(): Returns a pointer to an element at a specified locationtemplate <typename collectable_t> (const) collectable_t* const at((const) collection<collectable_t>& collection, index idx): Returns a pointer to the element at the specified index
begin(): Returns a begin iteratortemplate <typename collectable_t> typename collection<collectable_t>::iterator begin(collection<collectable_t>& collection)template <typename T> linked_iterator<T> begin(linked<T>& linked)
end(): Returns an end iteratortemplate <typename collectable_t> typename collection<collectable_t>::iterator end(collection<collectable_t>& collection)template <typename T> linked_iterator<T> end(linked<T>& linked)
wrap(): Wraps any subscriptable type to acollectiontemplate <typename T, index::int_type ssize> wrapper<T[ssize], T> wrap(T(&array)[ssize])template <typename T> wrapper<T*, T> wrap(T*& array, index::int_type ssize)
iterate(): Iterate through iteratortemplate <typename iterator_t> iterable<iterator_t> iterate(iterator_t begin, iterator_t end)template <typename array_t, index::int_type size> iterable<array_t*> iterate(array_t (&array)[size])template <typename iterator_t, typename dereference_t> enumerable<iterator_t, dereference_t>& iterate(enumerable<iterator_t, dereference_t>& enumerable)template <typename iterator_t, typename dereference_t> enumerable<iterator_t, dereference_t> iterate(enumerable<iterator_t, dereference_t>&& enumerable)template <typename collectable_t> collection<collectable_t>& iterate(collection<collectable_t>& collection)template <typename T> iterable<linked_iterator<T>> iterate(linked<T>& linked)template <typename collectable_t> iterable<const collectable_t*> iterate(const initializer_list<collectable_t>& init_list)
enumerate(): Enumerate iterator, returns an iterator that dereferences (operator*()) to aenumerationtemplate <typename iterator_t, typename dereference_t> enumerable<iterator_t, dereference_t> enumerate(iterator_t begin, iterator_t end)template <typename array_t, index::int_type size> enumerable<array_t*, array_t&> enumerate(array_t (&array)[size])template <typename collectable_t> enumerable<typename collection<collectable_t>::iterator, typename collection<collectable_t>::iterator_dereference_t> enumerate(collection<collectable_t>& collection)template <typename T> enumerable<linked_iterator<T>, T&> enumerate(linked<T>& linked)template <typename collectable_t> enumerable<const collectable_t*, const collectable_t&> enumerate(const initializer_list<collectable_t>& init_list)
hash(): hashes ahashable_twith default-hasher beinghasherfrom using-declarationtemplate <typename hashable_t, typename hasher_t = hasher<hashable_t>> index hash(const hashable_t& hashable)
Some implemented types have their own operators defined, but some operator overloads exist for all collections.
template <typename collectable_t> dynamic_collection<collectable_t>& operator+=(dynamic_collection<collectable_t>& collection, const collectable_t& item): forcol += item, adds to the endtemplate <typename collectable_t> dynamic_collection<collectable_t>& operator-=(dynamic_collection<collectable_t>& collection, const collectable_t& item): forcol -= item, removes if exists
- Platform-dependent Macros
- stdcol_platform_arduino
- stdcol_platform_macos
- stdcol_platform_linux
- stdcol_platform_windows
- stdcol_platform_generic
- stdcol_nostl
- The functional programming paradigm is best for this library has some function overloads that are more efficient for the data structure such as
iterate(linked)