Apama  10.15.1.2
com::softwareag::connectivity::map_t Class Reference

A map class which implements many of the functions on std::map. More...

#include <sag_connectivity_cpp.hpp>

Inheritance diagram for com::softwareag::connectivity::map_t:
com::softwareag::connectivity::metadata_t

Classes

struct  _iterator
 Forward/reverse and const/non-const iterators are implemented using this class. More...
 

Public Types

typedef _iterator< data_t, sag_underlying_map_table_entry_t *, pair< data_t > > iterator
 The type of iterators on mutable maps. More...
 
typedef _iterator< const data_t, sag_underlying_map_table_entry_t const *, const pair< const data_t > > const_iterator
 The type of iterators on const maps. More...
 
typedef pair< data_telement
 The type of an element in a mutable map. More...
 
typedef pair< const data_tconst_element
 The type of an element in a const map. More...
 
typedef std::pair< data_t, data_tinsertion_t
 The type of an element to be inserted into a map. More...
 

Public Member Functions

 map_t ()
 Construct an empty map. More...
 
 map_t (size_t n, const char *name=nullptr)
 Construct a map with (at least) capacity for n items and optional name. More...
 
 map_t (const char *name)
 Construct an empty map with a name. More...
 
 ~map_t ()
 Free the underlying map contents. More...
 
map_toperator= (map_t &&other)
 Move assignment. More...
 
 map_t (map_t &&other)
 Move constructor. More...
 
 map_t (std::initializer_list< std::pair< data_t, data_t >> l)
 Initializer list construction, for example map_t{ std::make_pair(data_t{"key1"},data_t{"val1"}), std::make_pair(data_t{"key2"},data_t{"val2"}) } More...
 
void swap (map_t &&other)
 Swap the contents of this map and other. More...
 
void swapName (map_t &&other)
 Swap the name of this map and other. More...
 
map_t copy () const
 Return a deep copy of this map. More...
 
void setName (const char *name)
 Set the optional name of this map. More...
 
const char * getName () const
 Get the optional name of this map. More...
 
bool operator== (const map_t &other) const
 Returns true if this map deep-equals other. More...
 
bool operator!= (const map_t &other) const
 Returns false if this map deep-equals other. More...
 
iterator begin ()
 Forward iterator begin. More...
 
iterator end ()
 Forward iterator end. More...
 
const_iterator begin () const
 Forward const_iterator begin. More...
 
const_iterator end () const
 Forward const_iterator end. More...
 
const_iterator cbegin () const
 Forward const_iterator begin. More...
 
const_iterator cend () const
 Forward const_iterator end. More...
 
size_t size () const
 Returns the number of key/value pairs in the map. More...
 
bool empty () const
 Returns true if the map is empty (size() == 0) More...
 
data_toperator[] (data_t &&k)
 Return a reference to the item with the given key. More...
 
data_toperator[] (const data_t &k)
 Return a reference to the item with the given key. More...
 
const data_toperator[] (const data_t &k) const
 Return a reference to the item with the given key. More...
 
iterator find (const data_t &k)
 Searches the map for an item with the given key and returns an iterator to that position in the map. More...
 
const_iterator find (const data_t &k) const
 Searches the map for an item with the given key and returns an iterator to that position in the map. More...
 
std::pair< iterator, bool > insert (insertion_t &&v)
 Insert a new key/value pair into the map. More...
 
std::pair< iterator, bool > insert (data_t &&k, data_t &&v)
 Insert a new key/value pair into the map. More...
 
size_t erase (const data_t &k)
 Remove the item with the specified key. More...
 
void erase (iterator it)
 Erase the item pointed to by this iterator. More...
 
void clear ()
 Empty the map, clean the name and free the underlying data. More...
 

Detailed Description

A map class which implements many of the functions on std::map.

This is an unordered map that can be named.

We don't guarantee exact method-for-method compatibility with any of the std types.

This class gives access methods to a map from data_t to data_t.

This is moveable, but not implicitly copyable. If you want to copy it use the .copy() method. If you want to move it use std::move().

No underlying implementation of the map is guaranteed. Modifying the contents will invalidate any iterators you have and any references that you have to the underlying structure.

Member Typedef Documentation

◆ const_element

The type of an element in a const map.

◆ const_iterator

typedef _iterator<const data_t, sag_underlying_map_table_entry_t const *, const pair<const data_t> > com::softwareag::connectivity::map_t::const_iterator

The type of iterators on const maps.

◆ element

The type of an element in a mutable map.

◆ insertion_t

The type of an element to be inserted into a map.

◆ iterator

typedef _iterator<data_t, sag_underlying_map_table_entry_t *, pair<data_t> > com::softwareag::connectivity::map_t::iterator

The type of iterators on mutable maps.

Constructor & Destructor Documentation

◆ map_t() [1/5]

com::softwareag::connectivity::map_t::map_t ( )
inline

Construct an empty map.

◆ map_t() [2/5]

com::softwareag::connectivity::map_t::map_t ( size_t  n,
const char *  name = nullptr 
)
explicit

Construct a map with (at least) capacity for n items and optional name.

◆ map_t() [3/5]

com::softwareag::connectivity::map_t::map_t ( const char *  name)
inlineexplicit

Construct an empty map with a name.

◆ ~map_t()

com::softwareag::connectivity::map_t::~map_t ( )
inline

Free the underlying map contents.

◆ map_t() [4/5]

com::softwareag::connectivity::map_t::map_t ( map_t &&  other)
inline

Move constructor.

Other will be left as the empty map

◆ map_t() [5/5]

com::softwareag::connectivity::map_t::map_t ( std::initializer_list< std::pair< data_t, data_t >>  l)
inline

Initializer list construction, for example map_t{ std::make_pair(data_t{"key1"},data_t{"val1"}), std::make_pair(data_t{"key2"},data_t{"val2"}) }

Member Function Documentation

◆ begin() [1/2]

iterator com::softwareag::connectivity::map_t::begin ( )
inline

Forward iterator begin.

◆ begin() [2/2]

const_iterator com::softwareag::connectivity::map_t::begin ( ) const
inline

Forward const_iterator begin.

◆ cbegin()

const_iterator com::softwareag::connectivity::map_t::cbegin ( ) const
inline

Forward const_iterator begin.

◆ cend()

const_iterator com::softwareag::connectivity::map_t::cend ( ) const
inline

Forward const_iterator end.

◆ clear()

void com::softwareag::connectivity::map_t::clear ( )

Empty the map, clean the name and free the underlying data.

◆ copy()

map_t com::softwareag::connectivity::map_t::copy ( ) const
inline

Return a deep copy of this map.

◆ empty()

bool com::softwareag::connectivity::map_t::empty ( ) const
inline

Returns true if the map is empty (size() == 0)

◆ end() [1/2]

iterator com::softwareag::connectivity::map_t::end ( )
inline

Forward iterator end.

◆ end() [2/2]

const_iterator com::softwareag::connectivity::map_t::end ( ) const
inline

Forward const_iterator end.

◆ erase() [1/2]

size_t com::softwareag::connectivity::map_t::erase ( const data_t k)

Remove the item with the specified key.

Returns the number of items removed (always 1)

◆ erase() [2/2]

void com::softwareag::connectivity::map_t::erase ( iterator  it)

Erase the item pointed to by this iterator.

If the iterator is end() this is a noop.

◆ find() [1/2]

iterator com::softwareag::connectivity::map_t::find ( const data_t k)

Searches the map for an item with the given key and returns an iterator to that position in the map.

If it is not found will return end().

◆ find() [2/2]

const_iterator com::softwareag::connectivity::map_t::find ( const data_t k) const

Searches the map for an item with the given key and returns an iterator to that position in the map.

If it is not found will return end().

◆ getName()

const char* com::softwareag::connectivity::map_t::getName ( ) const
inline

Get the optional name of this map.

Can return nullptr.

◆ insert() [1/2]

std::pair<iterator, bool> com::softwareag::connectivity::map_t::insert ( insertion_t &&  v)

Insert a new key/value pair into the map.

If the key already exists then the map is not modified and an iterator to the existing item is returned. Returns pair<iterator, bool> where the iterator points to the item with the given key and the boolean is true if the map needed to be modified with the new pair.

This is a move operator from the data_ts, so they will be left in the empty state. If you do not want this, use .copy(), otherwise use std::move

◆ insert() [2/2]

std::pair<iterator, bool> com::softwareag::connectivity::map_t::insert ( data_t &&  k,
data_t &&  v 
)
inline

Insert a new key/value pair into the map.

If the key already exists then the map is not modified and an iterator to the existing item is returned. Returns pair<iterator, bool> where the iterator points to the item with the given key and the boolean is true if the map needed to be modified with the new pair.

This is a move operator from the data_ts, so they will be left in the empty state. If you do not want this, use .copy(), otherwise use std::move

◆ operator!=()

bool com::softwareag::connectivity::map_t::operator!= ( const map_t other) const
inline

Returns false if this map deep-equals other.

◆ operator=()

map_t& com::softwareag::connectivity::map_t::operator= ( map_t &&  other)
inline

Move assignment.

Other will be left as the empty map and our previous contents will be freed.

◆ operator==()

bool com::softwareag::connectivity::map_t::operator== ( const map_t other) const
inline

Returns true if this map deep-equals other.

◆ operator[]() [1/3]

data_t& com::softwareag::connectivity::map_t::operator[] ( data_t &&  k)
inline

Return a reference to the item with the given key.

If k is not in the map then it inserts it and returns a reference to that. The reference is only valid until this map is mutated or deleted.

◆ operator[]() [2/3]

data_t& com::softwareag::connectivity::map_t::operator[] ( const data_t k)
inline

Return a reference to the item with the given key.

If k is not in the map then it inserts it and returns a reference to that The reference is only valid until this map is mutated or deleted.

◆ operator[]() [3/3]

const data_t& com::softwareag::connectivity::map_t::operator[] ( const data_t k) const
inline

Return a reference to the item with the given key.

If k is not in the map then throws std::runtime_error. The reference is only valid until this map is mutated or deleted.

◆ setName()

void com::softwareag::connectivity::map_t::setName ( const char *  name)
inline

Set the optional name of this map.

nullptr to undefine

◆ size()

size_t com::softwareag::connectivity::map_t::size ( ) const
inline

Returns the number of key/value pairs in the map.

◆ swap()

void com::softwareag::connectivity::map_t::swap ( map_t &&  other)
inline

Swap the contents of this map and other.

◆ swapName()

void com::softwareag::connectivity::map_t::swapName ( map_t &&  other)
inline

Swap the name of this map and other.


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