retdec
Classes | Namespaces
container.h File Reference

Container utilities. More...

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
#include "retdec/utils/filter_iterator.h"

Go to the source code of this file.

Classes

class  retdec::utils::NonIterableSet< Elem >
 
struct  retdec::utils::EnumClassKeyHash
 

Namespaces

 retdec
 
 retdec::utils
 

Functions

General Operations with Containers
template<class Container , typename Item >
bool retdec::utils::hasItem (const Container &container, const Item &item)
 Returns true if container contains item, false otherwise. More...
 
template<typename Item >
bool retdec::utils::hasItem (const std::list< Item > &container, const Item &item)
 A "specialization" of hasItem<>() for std::list. More...
 
template<typename Item >
bool retdec::utils::hasItem (const std::vector< Item > &container, const Item &item)
 A "specialization" of hasItem<>() for std::vector. More...
 
template<typename Item >
const Item & retdec::utils::getNthItem (const std::vector< Item > &container, std::size_t n)
 Returns the n-th item in container. More...
 
template<typename Item >
const Item & retdec::utils::getNthItem (const std::list< Item > &container, std::size_t n)
 Returns the n-th item in container. More...
 
template<class Container , typename Item >
Item retdec::utils::getValueOrDefault (const Container &container, const Item &item, Item defaultValue=Item())
 Returns the found value if container contains item, defaultValue otherwise. More...
 
template<typename Item >
Item retdec::utils::getValueOrDefault (const std::list< Item > &container, const Item &item, Item defaultValue=Item())
 A "specialization" of getValueOrDefault<>() for std::list. More...
 
template<typename Item >
Item retdec::utils::getValueOrDefault (const std::vector< Item > &container, const Item &item, Item defaultValue=Item())
 A "specialization" of getValueOrDefault<>() for std::vector. More...
 
template<typename Item >
void retdec::utils::removeItem (std::vector< Item > &v, const Item &item)
 Removes all occurrences of the given item from the given vector. More...
 
template<class Container >
void retdec::utils::clear (Container &container)
 Clears the given container. More...
 
template<typename Item >
void retdec::utils::clear (std::queue< Item > &q)
 A "specialization" of clear<>() for std::queue. More...
 
template<typename Item >
void retdec::utils::clear (std::stack< Item > &s)
 A "specialization" of clear<>() for std::stack. More...
 
template<typename OutputContainer , typename InputContainer , typename Predicate >
OutputContainer retdec::utils::filterTo (const InputContainer &input, const Predicate &predicate)
 Returns OutputContainer with items from input that satistfy predicate. More...
 
template<typename Container , typename Predicate >
Container retdec::utils::filter (const Container &input, const Predicate &predicate)
 Returns Container with items from input that satistfy predicate. More...
 
Operations with Sets
template<typename T >
void retdec::utils::addToSet (const std::set< T > &from, std::set< T > &to)
 Adds all values from from into to. More...
 
template<typename T >
std::set< T > retdec::utils::setUnion (const std::set< T > &s1, const std::set< T > &s2)
 Returns the set union s1 \cup s2. More...
 
template<typename T >
std::set< T > retdec::utils::setIntersection (const std::set< T > &s1, const std::set< T > &s2)
 Returns the set intersection s1 \cap s2. More...
 
template<typename T >
std::set< T > retdec::utils::setDifference (const std::set< T > &s1, const std::set< T > &s2)
 Returns the set difference s1 \setminus s2. More...
 
template<typename T >
void retdec::utils::removeFromSet (std::set< T > &from, const std::set< T > &toRemove)
 Removes all values that are in toRemove from from. More...
 
template<typename T >
bool retdec::utils::areDisjoint (const std::set< T > &s1, const std::set< T > &s2)
 Returns true if s1 is disjoint with s2. More...
 
template<typename T >
bool retdec::utils::shareSomeItem (const std::set< T > &s1, const std::set< T > &s2)
 Returns true if s1 and s2 have at least one item in common. More...
 
Operations with Maps
template<typename Map >
std::set< typename Map::key_type > retdec::utils::getKeysFromMap (const Map &m)
 Returns all keys in the given map m. More...
 
template<typename Map >
std::set< typename Map::mapped_type > retdec::utils::getValuesFromMap (const Map &m)
 Returns all values in the given map m. More...
 
template<typename Map >
bool retdec::utils::mapHasKey (const Map &m, const typename Map::key_type &k)
 Returns true if the given map m has a key k, false otherwise. More...
 
template<typename Map >
bool retdec::utils::mapHasValue (const Map &m, const typename Map::mapped_type &v)
 Returns true if the given map m has a value v, false otherwise. More...
 
template<typename Map >
Map::mapped_type retdec::utils::mapGetValueOrDefault (const Map &m, const typename Map::key_type &key, typename Map::mapped_type defaultValue=typename Map::mapped_type())
 Returns the value associated to the given key in m, or defaultValue if there is no key in m. More...
 
template<typename Map >
Map::mapped_type retdec::utils::mapGetMaxValue (const Map &m)
 Returns the maximum value from m. More...
 
template<typename Map >
Map::mapped_type & retdec::utils::addToMap (const typename Map::key_type &key, const typename Map::mapped_type &value, Map &m)
 Adds the pair <key, value> to map m. More...
 
template<typename K , typename V >
std::map< V, K > retdec::utils::getMapWithSwappedKeysAndValues (const std::map< K, V > &m)
 Returns a new map that has swapped keys and values. More...
 

Detailed Description

Container utilities.