Public Types | Public Member Functions | Public Attributes | List of all members
WireCell::IndexedSet< TYPE > Class Template Reference

#include <IndexedSet.h>

Public Types

typedef std::unordered_map< TYPE, int > index_type
 
typedef std::vector< TYPE > collection_type
 
typedef collection_type::size_type size_type
 

Public Member Functions

size_type size ()
 
int operator() (const TYPE &obj) const
 
int operator() (const TYPE &obj)
 
bool has (const TYPE &obj)
 

Public Attributes

index_type index
 
collection_type collection
 

Detailed Description

template<class TYPE>
class WireCell::IndexedSet< TYPE >

IndexedSet - maintain a collection of exactly one thing in a first added order

Definition at line 13 of file IndexedSet.h.

Member Typedef Documentation

template<class TYPE>
typedef std::vector<TYPE> WireCell::IndexedSet< TYPE >::collection_type

Definition at line 18 of file IndexedSet.h.

template<class TYPE>
typedef std::unordered_map<TYPE, int> WireCell::IndexedSet< TYPE >::index_type

Definition at line 17 of file IndexedSet.h.

template<class TYPE>
typedef collection_type::size_type WireCell::IndexedSet< TYPE >::size_type

Definition at line 19 of file IndexedSet.h.

Member Function Documentation

template<class TYPE>
bool WireCell::IndexedSet< TYPE >::has ( const TYPE &  obj)
inline

Definition at line 43 of file IndexedSet.h.

43  {
44  auto mit = index.find(obj);
45  return mit != index.end();
46  }
index_type index
Definition: IndexedSet.h:21
template<class TYPE>
int WireCell::IndexedSet< TYPE >::operator() ( const TYPE &  obj) const
inline

Definition at line 25 of file IndexedSet.h.

25  {
26  auto mit = index.find(obj);
27  if (mit != index.end()) {
28  return mit->second;
29  }
30  return -1;
31  }
index_type index
Definition: IndexedSet.h:21
template<class TYPE>
int WireCell::IndexedSet< TYPE >::operator() ( const TYPE &  obj)
inline

Definition at line 32 of file IndexedSet.h.

32  {
33  auto mit = index.find(obj);
34  if (mit != index.end()) {
35  return mit->second;
36  }
37  int index_number = collection.size();
38  index[obj] = index_number;
39  collection.push_back(obj);
40  return index_number;
41  }
collection_type collection
Definition: IndexedSet.h:22
index_type index
Definition: IndexedSet.h:21
template<class TYPE>
size_type WireCell::IndexedSet< TYPE >::size ( void  )
inline

Definition at line 23 of file IndexedSet.h.

23 { return collection.size(); }
collection_type collection
Definition: IndexedSet.h:22

Member Data Documentation

template<class TYPE>
collection_type WireCell::IndexedSet< TYPE >::collection

Definition at line 22 of file IndexedSet.h.

template<class TYPE>
index_type WireCell::IndexedSet< TYPE >::index

Definition at line 21 of file IndexedSet.h.


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