Minsky
minsky::IntrusiveMap< Key, Val > Class Template Reference

#include <intrusiveMap.h>

Inheritance diagram for minsky::IntrusiveMap< Key, Val >:
Inheritance graph
Collaboration diagram for minsky::IntrusiveMap< Key, Val >:
Collaboration graph

Classes

struct  iterator
 

Public Types

typedef Super::const_iterator const_iterator
 
typedef Super::value_type value_type
 
typedef Key key_type
 
typedef Val mapped_type
 

Public Member Functions

template<class... A>
 IntrusiveMap (A... a)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator find (const Key &k)
 
const_iterator find (const Key &k) const
 
size_t count (const Key &k) const
 
std::pair< iterator, bool > insert (const value_type &x)
 
template<class I1 , class I2 >
void insert (I1 i1, I2 i2)
 
void insert (const Key &k, const Val &v)
 
value_typeoperator[] (const Key &k)
 
value_type operator[] (const Key &k) const
 
void swap (IntrusiveMap &x)
 
std::set< Key > keys () const
 

Public Attributes

std::set< Key > updateAccess
 track writeable access into this Map More...
 

Private Types

typedef std::set< IntrusiveWrap< Key, Val > > Super
 

Detailed Description

template<class Key, class Val>
class minsky::IntrusiveMap< Key, Val >

An intrusive map is like a std::map, except that the value type must include an member "id" of type Key, which holds the key value.

Definition at line 82 of file intrusiveMap.h.

Member Typedef Documentation

◆ const_iterator

template<class Key, class Val>
typedef Super::const_iterator minsky::IntrusiveMap< Key, Val >::const_iterator

Definition at line 86 of file intrusiveMap.h.

◆ key_type

template<class Key, class Val>
typedef Key minsky::IntrusiveMap< Key, Val >::key_type

Definition at line 88 of file intrusiveMap.h.

◆ mapped_type

template<class Key, class Val>
typedef Val minsky::IntrusiveMap< Key, Val >::mapped_type

Definition at line 89 of file intrusiveMap.h.

◆ Super

template<class Key, class Val>
typedef std::set<IntrusiveWrap<Key, Val> > minsky::IntrusiveMap< Key, Val >::Super
private

Definition at line 84 of file intrusiveMap.h.

◆ value_type

template<class Key, class Val>
typedef Super::value_type minsky::IntrusiveMap< Key, Val >::value_type

Definition at line 87 of file intrusiveMap.h.

Constructor & Destructor Documentation

◆ IntrusiveMap()

template<class Key, class Val>
template<class... A>
minsky::IntrusiveMap< Key, Val >::IntrusiveMap ( A...  a)
inlineexplicit

Definition at line 94 of file intrusiveMap.h.

94 : Super(std::forward<A>(a)...) {}
std::set< IntrusiveWrap< Key, Val > > Super
Definition: intrusiveMap.h:84

Member Function Documentation

◆ begin() [1/2]

template<class Key, class Val>
iterator minsky::IntrusiveMap< Key, Val >::begin ( )
inline

Definition at line 115 of file intrusiveMap.h.

115 {return iterator(Super::begin());}

◆ begin() [2/2]

template<class Key, class Val>
const_iterator minsky::IntrusiveMap< Key, Val >::begin ( ) const
inline

Definition at line 116 of file intrusiveMap.h.

116 {return Super::begin();}

◆ count()

template<class Key, class Val>
size_t minsky::IntrusiveMap< Key, Val >::count ( const Key &  k) const
inline

Definition at line 127 of file intrusiveMap.h.

127 {return Super::count(value_type(k));}
Super::value_type value_type
Definition: intrusiveMap.h:87

◆ end() [1/2]

template<class Key, class Val>
iterator minsky::IntrusiveMap< Key, Val >::end ( )
inline

Definition at line 118 of file intrusiveMap.h.

Referenced by minsky::IntrusiveMap< K, V >::operator[]().

118 {return iterator(Super::end());}
Here is the caller graph for this function:

◆ end() [2/2]

template<class Key, class Val>
const_iterator minsky::IntrusiveMap< Key, Val >::end ( ) const
inline

Definition at line 119 of file intrusiveMap.h.

119 {return Super::end();}

◆ find() [1/2]

template<class Key, class Val>
iterator minsky::IntrusiveMap< Key, Val >::find ( const Key &  k)
inline

Definition at line 121 of file intrusiveMap.h.

Referenced by minsky::IntrusiveMap< K, V >::operator[]().

121  {
122  updateAccess.insert(k);
123  return iterator(Super::find(value_type(k)));
124  }
std::set< Key > updateAccess
track writeable access into this Map
Definition: intrusiveMap.h:92
Super::value_type value_type
Definition: intrusiveMap.h:87
Here is the caller graph for this function:

◆ find() [2/2]

template<class Key, class Val>
const_iterator minsky::IntrusiveMap< Key, Val >::find ( const Key &  k) const
inline

Definition at line 125 of file intrusiveMap.h.

125 {return Super::find(value_type(k));}
Super::value_type value_type
Definition: intrusiveMap.h:87

◆ insert() [1/3]

template<class Key, class Val>
std::pair<iterator, bool> minsky::IntrusiveMap< Key, Val >::insert ( const value_type x)
inline

Definition at line 129 of file intrusiveMap.h.

Referenced by minsky::IntrusiveMap< K, V >::insert().

129  {
130  std::pair<const_iterator, bool> p = Super::insert(x);
131  return make_pair(iterator(p.first), p.second);
132  }
Here is the caller graph for this function:

◆ insert() [2/3]

template<class Key, class Val>
template<class I1 , class I2 >
void minsky::IntrusiveMap< Key, Val >::insert ( I1  i1,
I2  i2 
)
inline

Definition at line 135 of file intrusiveMap.h.

135 {Super::insert(i1,i2);}

◆ insert() [3/3]

template<class Key, class Val>
void minsky::IntrusiveMap< Key, Val >::insert ( const Key &  k,
const Val &  v 
)
inline

Definition at line 137 of file intrusiveMap.h.

138  {insert(value_type(k,v));}
std::pair< iterator, bool > insert(const value_type &x)
Definition: intrusiveMap.h:129
Super::value_type value_type
Definition: intrusiveMap.h:87

◆ keys()

template<class Key, class Val>
std::set<Key> minsky::IntrusiveMap< Key, Val >::keys ( ) const
inline

Definition at line 157 of file intrusiveMap.h.

157  {
158  std::set<Key> r;
159  for (const value_type& i: *this)
160  r.insert(i.id());
161  return r;
162  }
Super::value_type value_type
Definition: intrusiveMap.h:87

◆ operator[]() [1/2]

template<class Key, class Val>
value_type& minsky::IntrusiveMap< Key, Val >::operator[] ( const Key &  k)
inline

Definition at line 140 of file intrusiveMap.h.

140  {
141  const_iterator it=find(k);
142  if (it==end())
143  it = Super::insert(value_type(k)).first;
144  return const_cast<value_type&>(*it);
145  }
Super::const_iterator const_iterator
Definition: intrusiveMap.h:86
iterator find(const Key &k)
Definition: intrusiveMap.h:121
Super::value_type value_type
Definition: intrusiveMap.h:87

◆ operator[]() [2/2]

template<class Key, class Val>
value_type minsky::IntrusiveMap< Key, Val >::operator[] ( const Key &  k) const
inline

Definition at line 147 of file intrusiveMap.h.

147  {
148  const_iterator it=find(k);
149  if (it==end())
150  return value_type(k);
151  else
152  return *it;
153  }
Super::const_iterator const_iterator
Definition: intrusiveMap.h:86
iterator find(const Key &k)
Definition: intrusiveMap.h:121
Super::value_type value_type
Definition: intrusiveMap.h:87

◆ swap()

template<class Key, class Val>
void minsky::IntrusiveMap< Key, Val >::swap ( IntrusiveMap< Key, Val > &  x)
inline

Definition at line 155 of file intrusiveMap.h.

155 {Super::swap(x);}

Member Data Documentation

◆ updateAccess

template<class Key, class Val>
std::set<Key> minsky::IntrusiveMap< Key, Val >::updateAccess

track writeable access into this Map

Definition at line 92 of file intrusiveMap.h.

Referenced by minsky::IntrusiveMap< K, V >::find().


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