CBuild
C++ build system with scripts written in c++
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
lib::map< _K, _D > Class Template Reference

Simple map implementation with some stack operation added. More...

#include <map.hpp>

Public Member Functions

 map ()
 Construct a new map object.
 
 map (map const &)=default
 Copy constructor.
 
 map (std::initializer_list< lib::mapData< _K, _D > > init_list)
 Consruct a new map object and initialize it.
 
void push_back (lib::mapData< _K, _D > element)
 Push new element to map, stack operation ! Dangerous not perform chak if this elemnt exists in map.
 
void push_back (_K key, _D data)
 Push new element to map, stack operation ! Dangerous not perform chak if this elemnt exists in map.
 
void push_back_check (lib::mapData< _K, _D > element)
 Add data, but check if key exists, if exist - trow exception.
 
void push_back_check (_K key, _D data)
 Add data, but check if key exists, if exist - trow exception.
 
lib::mapData< _K, _D > pop_back ()
 Pop last element, remove it and return back it's copy.
 
const _D * get (_K key)
 Get element by it's key.
 
lib::mapData< _K, _D > * get_ptr (_K key)
 Get reference to key and value of map.
 
bool contains_key (_K key)
 Does map contains some key.
 
bool contains (_D value)
 Does map contains some value.
 
void clear ()
 Erase all elements (simmilar to std::vector::clear())
 
lib::mapData< _K, _D > at (__SIZE_TYPE__ i)
 Array operation, get element at index.
 
lib::mapData< _K, _D > * ptr_at (__SIZE_TYPE__ i)
 Array operation, get pointer to an element at specified index.
 
void remove (__SIZE_TYPE__ idx)
 Remove element from map and return copy of this element.
 
void remove (_K key)
 Remove element with given key.
 
std::vector< _K > keys ()
 Get keys list.
 
__SIZE_TYPE__ size ()
 Size of map.
 
lib::mapData< _K, _D > operator[] (__SIZE_TYPE__ i)
 Typical array operation, simmilar to at but using operator [].
 
lib::map< _K, _D > operator+ (lib::mapData< _K, _D > val)
 Add one elment to map.
 
lib::map< _K, _D > operator+= (lib::mapData< _K, _D > val)
 Add one element to map, modify it.
 
lib::map< _K, _D > operator+ (lib::map< _K, _D > val)
 Add another map to this map.
 
lib::map< _K, _D > operator+= (lib::map< _K, _D > val)
 Add another map to this, modify it.
 
lib::map< _K, _D > operator= (lib::map< _K, _D > val)
 Copy content of second map to first.
 
lib::map< _K, _D > operator= (lib::mapData< _K, _D > val)
 Reset map, set first it's element to val.
 
bool operator== (lib::map< _K, _D > val)
 Check if content of two maps is equal.
 
std::vector< mapData< _K, _D > >::iterator begin ()
 Begin iterator.
 
std::vector< mapData< _K, _D > >::iterator end ()
 End iterator.
 
std::vector< mapData< _K, _D > >::const_iterator begin () const
 Begin const iterator.
 
std::vector< mapData< _K, _D > >::const_iterator end () const
 End const iterator.
 
bool empty ()
 Simmilar to std::vector::empty.
 
void erase (_K key)
 

Private Attributes

std::vector< mapData< _K, _D > > content
 

Detailed Description

template<class _K, class _D>
class lib::map< _K, _D >

Simple map implementation with some stack operation added.

Template Parameters
_K-> Key, must have "==" operator implemented
_D-> Value
All types must implement "=" operator

Definition at line 79 of file map.hpp.

Constructor & Destructor Documentation

◆ map() [1/3]

template<class _K , class _D >
lib::map< _K, _D >::map ( )
inline

◆ map() [2/3]

template<class _K , class _D >
lib::map< _K, _D >::map ( map< _K, _D > const & )
default

Copy constructor.

◆ map() [3/3]

template<class _K , class _D >
lib::map< _K, _D >::map ( std::initializer_list< lib::mapData< _K, _D > > init_list)
inline

Consruct a new map object and initialize it.

Parameters
init_list=> std::initializer_list -> New map data

Definition at line 99 of file map.hpp.

Member Function Documentation

◆ at()

template<class _K , class _D >
lib::mapData< _K, _D > lib::map< _K, _D >::at ( __SIZE_TYPE__ i)
inline

Array operation, get element at index.

Parameters
i=> size_t -> index
Returns
lib::mapData<_K, _D> -> returned element

Definition at line 223 of file map.hpp.

Referenced by CBuild::gcc_hash_impl(), CBuild::Toolchain::gen_file_list(), CBuild::ccj_out::generate(), and CBuild::loop().

◆ begin() [1/2]

template<class _K , class _D >
std::vector< mapData< _K, _D > >::iterator lib::map< _K, _D >::begin ( )
inline

Begin iterator.

Returns
std::vector<mapData<_K, _D>>::iterator -> begin iterator

Definition at line 373 of file map.hpp.

◆ begin() [2/2]

template<class _K , class _D >
std::vector< mapData< _K, _D > >::const_iterator lib::map< _K, _D >::begin ( ) const
inline

Begin const iterator.

Returns
std::vector<mapData<_K, _D>>::const_iterator -> begin const iterator

Definition at line 388 of file map.hpp.

◆ clear()

template<class _K , class _D >
void lib::map< _K, _D >::clear ( )
inline

Erase all elements (simmilar to std::vector::clear())

Definition at line 215 of file map.hpp.

Referenced by CBuild::Toolchain::gen_file_list().

◆ contains()

template<class _K , class _D >
bool lib::map< _K, _D >::contains ( _D value)
inline

Does map contains some value.

Parameters
value=> _D -> Value
Returns
true -> Contains
false -> Not contains

Definition at line 205 of file map.hpp.

References lib::map< _K, _D >::content.

◆ contains_key()

template<class _K , class _D >
bool lib::map< _K, _D >::contains_key ( _K key)
inline

Does map contains some key.

Parameters
key=> _K -> Key
Returns
true -> Contains
false -> Not contains

Definition at line 192 of file map.hpp.

References lib::map< _K, _D >::content.

◆ empty()

template<class _K , class _D >
bool lib::map< _K, _D >::empty ( )
inline

Simmilar to std::vector::empty.

Definition at line 402 of file map.hpp.

◆ end() [1/2]

template<class _K , class _D >
std::vector< mapData< _K, _D > >::iterator lib::map< _K, _D >::end ( )
inline

End iterator.

Returns
std::vector<mapData<_K, _D>>::iterator -> end iterator

Definition at line 380 of file map.hpp.

◆ end() [2/2]

template<class _K , class _D >
std::vector< mapData< _K, _D > >::const_iterator lib::map< _K, _D >::end ( ) const
inline

End const iterator.

Returns
std::vector<mapData<_K, _D>>::const_iterator -> end const iterator

Definition at line 396 of file map.hpp.

◆ erase()

template<class _K , class _D >
void lib::map< _K, _D >::erase ( _K key)
inline

Definition at line 405 of file map.hpp.

◆ get()

template<class _K , class _D >
const _D * lib::map< _K, _D >::get ( _K key)
inline

Get element by it's key.

Parameters
key=> _D -> Key
Returns
const _D* -> Returned element const reference

Definition at line 159 of file map.hpp.

References lib::mapData< _K, _D >::data, and lib::mapData< _K, _D >::key.

Referenced by check_mismatch_recursive(), check_mismatch_recursive(), CBuild::ccj_out::generate(), CBuild::makefile_out::generate(), CBuild::loop(), lib::map< _K, _D >::push_back_check(), and lib::map< _K, _D >::push_back_check().

◆ get_ptr()

template<class _K , class _D >
lib::mapData< _K, _D > * lib::map< _K, _D >::get_ptr ( _K key)
inline

Get reference to key and value of map.

Parameters
key=> _K -> key that is needed
Returns
lib::mapData<_K, _D>* -> returned reference

Definition at line 175 of file map.hpp.

References lib::mapData< _K, _D >::key.

Referenced by CBuild::build_handler(), CBuild::ccj_out::generate(), CBuild::generator_handler(), CBuild::loop(), CBuild::out_handler(), and CBuild::task_handler().

◆ keys()

template<class _K , class _D >
std::vector< _K > lib::map< _K, _D >::keys ( )
inline

Get keys list.

Returns
std::vector<_K> -> list of keys

Definition at line 264 of file map.hpp.

References lib::map< _K, _D >::content.

◆ operator+() [1/2]

template<class _K , class _D >
lib::map< _K, _D > lib::map< _K, _D >::operator+ ( lib::map< _K, _D > val)
inline

Add another map to this map.

Parameters
val=> lib::map<_K, _D> -> another map
Returns
lib::map<_K, _D> -> map

Definition at line 314 of file map.hpp.

References lib::map< _K, _D >::content, and lib::map< _K, _D >::map().

◆ operator+() [2/2]

template<class _K , class _D >
lib::map< _K, _D > lib::map< _K, _D >::operator+ ( lib::mapData< _K, _D > val)
inline

Add one elment to map.

Parameters
val=> lib::mapData<_K, _D> -> element
Returns
lib::map<_K, _D> -> map

Definition at line 291 of file map.hpp.

References lib::map< _K, _D >::content, and lib::map< _K, _D >::map().

◆ operator+=() [1/2]

template<class _K , class _D >
lib::map< _K, _D > lib::map< _K, _D >::operator+= ( lib::map< _K, _D > val)
inline

Add another map to this, modify it.

Parameters
val=> lib::map<_K, _D> -> another map
Returns
lib::map<_K, _D> -> map

Definition at line 327 of file map.hpp.

References lib::map< _K, _D >::content, and lib::map< _K, _D >::map().

◆ operator+=() [2/2]

template<class _K , class _D >
lib::map< _K, _D > lib::map< _K, _D >::operator+= ( lib::mapData< _K, _D > val)
inline

Add one element to map, modify it.

Parameters
val=> lib::mapData<_K, _D> -> element
Returns
lib::map<_K, _D> -> map

Definition at line 302 of file map.hpp.

References lib::map< _K, _D >::content, and lib::map< _K, _D >::map().

◆ operator=() [1/2]

template<class _K , class _D >
lib::map< _K, _D > lib::map< _K, _D >::operator= ( lib::map< _K, _D > val)
inline

Copy content of second map to first.

Parameters
val=> lib::map<_K, _D> -> another map
Returns
lib::map<_K, _D> -> map

Definition at line 341 of file map.hpp.

References lib::map< _K, _D >::content.

◆ operator=() [2/2]

template<class _K , class _D >
lib::map< _K, _D > lib::map< _K, _D >::operator= ( lib::mapData< _K, _D > val)
inline

Reset map, set first it's element to val.

Parameters
val=> lib::mapData<_K, _D> -> mapData variable
Returns
lib::map<_K, _D> -> map

Definition at line 350 of file map.hpp.

◆ operator==()

template<class _K , class _D >
bool lib::map< _K, _D >::operator== ( lib::map< _K, _D > val)
inline

Check if content of two maps is equal.

Parameters
val=> lib::map<_K, _D> -> map variable
Returns
bool -> standart comparion rules

Definition at line 360 of file map.hpp.

References lib::map< _K, _D >::content.

◆ operator[]()

template<class _K , class _D >
lib::mapData< _K, _D > lib::map< _K, _D >::operator[] ( __SIZE_TYPE__ i)
inline

Typical array operation, simmilar to at but using operator [].

Parameters
i=> size_t -> Index
Returns
lib::mapData<_K, _D> -> Returned element

Definition at line 283 of file map.hpp.

◆ pop_back()

template<class _K , class _D >
lib::mapData< _K, _D > lib::map< _K, _D >::pop_back ( )
inline

Pop last element, remove it and return back it's copy.

Returns
lib::mapData<_K, _D> -> Returned element

Definition at line 149 of file map.hpp.

◆ ptr_at()

template<class _K , class _D >
lib::mapData< _K, _D > * lib::map< _K, _D >::ptr_at ( __SIZE_TYPE__ i)
inline

Array operation, get pointer to an element at specified index.

Parameters
i=> size_t -> Index
Returns
lib::mapData<_K, _D>* -> Returned element pointer

Definition at line 232 of file map.hpp.

Referenced by CBuild::gcc_hash_impl(), and CBuild::CBuildHashV2::get_files_for_recompilation().

◆ push_back() [1/2]

template<class _K , class _D >
void lib::map< _K, _D >::push_back ( _K key,
_D data )
inline

Push new element to map, stack operation ! Dangerous not perform chak if this elemnt exists in map.

Parameters
key=> _K -> Key
data=> _D -> Value

Definition at line 120 of file map.hpp.

◆ push_back() [2/2]

template<class _K , class _D >
void lib::map< _K, _D >::push_back ( lib::mapData< _K, _D > element)
inline

Push new element to map, stack operation ! Dangerous not perform chak if this elemnt exists in map.

Parameters
element=> lib::mapData<_K, _D> -> mapData object, that pack key and value to one variable

Definition at line 111 of file map.hpp.

Referenced by CBuild::gcc_hash_impl(), CBuild::Toolchain::gen_file_list(), CBuild::ccj_out::generate(), CBuild::CBuildHashV2::get_files_for_recompilation(), CBuild::CBuildHash::get_files_for_recompilation(), lib::map< _K, _D >::push_back_check(), and lib::map< _K, _D >::push_back_check().

◆ push_back_check() [1/2]

template<class _K , class _D >
void lib::map< _K, _D >::push_back_check ( _K key,
_D data )
inline

Add data, but check if key exists, if exist - trow exception.

Exceptions
runtime_error-> string with error descitption
Parameters
key=> _K -> key
data=> _D -> Data

Definition at line 140 of file map.hpp.

References lib::map< _K, _D >::get(), and lib::map< _K, _D >::push_back().

◆ push_back_check() [2/2]

template<class _K , class _D >
void lib::map< _K, _D >::push_back_check ( lib::mapData< _K, _D > element)
inline

Add data, but check if key exists, if exist - trow exception.

Exceptions
runtime_error-> string with error descitption
Parameters
element=> lib::mapData<_K, _D> -> New element to push

Definition at line 129 of file map.hpp.

References lib::map< _K, _D >::get(), lib::mapData< _K, _D >::key, and lib::map< _K, _D >::push_back().

Referenced by CBuild::arg_handler(), CBuild::build_handler(), CBuild::force_handler(), CBuild::gcc_hash_impl(), CBuild::generator_handler(), CBuild::out_handler(), CBuild::parse(), parse_file(), CBuild::rebuild_handler(), and CBuild::task_handler().

◆ remove() [1/2]

template<class _K , class _D >
void lib::map< _K, _D >::remove ( __SIZE_TYPE__ idx)
inline

Remove element from map and return copy of this element.

Parameters
idxIndex of element to remove

Definition at line 239 of file map.hpp.

◆ remove() [2/2]

template<class _K , class _D >
void lib::map< _K, _D >::remove ( _K key)
inline

Remove element with given key.

Parameters
key=> _K -> Key of elent that is needed to be removed

Definition at line 248 of file map.hpp.

References lib::mapData< _K, _D >::key.

◆ size()

template<class _K , class _D >
__SIZE_TYPE__ lib::map< _K, _D >::size ( )
inline

Size of map.

Returns
size_t -> Number of elements

Definition at line 275 of file map.hpp.

Referenced by CBuild::gcc_hash_impl(), CBuild::Toolchain::gen_file_list(), CBuild::ccj_out::generate(), CBuild::CBuildHashV2::get_files_for_recompilation(), and CBuild::loop().

Member Data Documentation

◆ content

template<class _K , class _D >
std::vector<mapData<_K, _D> > lib::map< _K, _D >::content
private

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