src
Classes | Public Member Functions | List of all members
re2c::ord_hash_set_t Class Reference

#include <ord_hash_set.h>

Public Member Functions

 ord_hash_set_t ()
 
 ~ord_hash_set_t ()
 
size_t size () const
 
size_t insert (const void *data, size_t size)
 
template<typename data_t >
size_t deref (size_t i, data_t *&data)
 

Detailed Description

Definition at line 19 of file ord_hash_set.h.

Constructor & Destructor Documentation

re2c::ord_hash_set_t::ord_hash_set_t ( )

Definition at line 69 of file ord_hash_set.h.

70  : elems()
71  , lookup()
72 {}
re2c::ord_hash_set_t::~ord_hash_set_t ( )

Definition at line 74 of file ord_hash_set.h.

75 {
76  std::for_each(elems.begin(), elems.end(), free);
77 }

Member Function Documentation

template<typename data_t >
size_t re2c::ord_hash_set_t::deref ( size_t  i,
data_t *&  data 
)

Definition at line 106 of file ord_hash_set.h.

107 {
108  elem_t *e = elems[i];
109  data = reinterpret_cast<data_t*>(e->data);
110  return e->size / sizeof(data_t);
111 }

Here is the caller graph for this function:

size_t re2c::ord_hash_set_t::insert ( const void *  data,
size_t  size 
)

Definition at line 84 of file ord_hash_set.h.

85 {
86  const hash_t h = hash(data, size);
87 
88  std::map<hash_t, elem_t*>::const_iterator i = lookup.find(h);
89  if (i != lookup.end())
90  {
91  for (elem_t *e = i->second; e; e = e->next)
92  {
93  if (e->size == size
94  && memcmp(e->data, data, size) == 0)
95  {
96  return e->index;
97  }
98  }
99  }
100 
101  const size_t index = elems.size();
102  elems.push_back(lookup[h] = make_elem(lookup[h], index, size, data));
103  return index;
104 }
size_t size() const
Definition: ord_hash_set.h:79

Here is the caller graph for this function:

size_t re2c::ord_hash_set_t::size ( ) const

Definition at line 79 of file ord_hash_set.h.

80 {
81  return elems.size();
82 }

Here is the caller graph for this function:


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