41 #ifndef AS_SYMBOLTABLE_H 42 #define AS_SYMBOLTABLE_H 44 #include "as_config.h" 45 #include "as_memory.h" 46 #include "as_string.h" 48 #include "as_datatype.h" 49 #include "as_namespace.h" 60 virtual bool operator()(
const void *)
const = 0;
75 template<
class T,
class T2 = T>
78 T2 *operator*()
const;
79 T2 *operator->()
const;
82 operator bool()
const;
83 int GetIndex()
const {
114 int GetLastIndex()
const;
116 int GetIndex(
const T *)
const;
121 T *Get(asUINT index);
122 const T *Get(asUINT index)
const;
124 const T *GetLast()
const;
128 asUINT Put(T *entry);
130 asUINT GetSize()
const;
135 bool Erase(asUINT idx);
136 void Allocate(asUINT elem_cnt,
bool keep_data);
139 const_iterator List()
const;
151 bool CheckIdx(asUINT idx)
const;
163 m_map.SwapWith(other.m_map);
164 m_entries.SwapWith(other.m_entries);
167 m_size = other.m_size;
191 if (m_map.MoveTo(&cursor, key)) {
193 for (asUINT n = 0; n < arr.GetLength(); n++) {
194 T *entry = m_entries[arr[n]];
195 if (entry && filter(entry))
210 if (m_map.MoveTo(&cursor, key))
211 return m_map.GetValue(cursor);
222 int idx = GetFirstIndex(ns, name, comp);
223 if (idx != -1)
return m_entries[idx];
235 if (m_map.MoveTo(&cursor, key))
236 return m_map.GetValue(cursor)[0];
248 for (asUINT n = 0; n < m_entries.GetLength(); n++)
249 if (m_entries[n] == entry)
265 return m_entries[idx];
279 int idx = GetFirstIndex(ns, name);
294 return Get(GetLastIndex());
310 m_entries.SetLength(0);
321 asASSERT(elemCnt >= m_entries.GetLength());
322 m_entries.Allocate(elemCnt, keepData);
331 if (!CheckIdx(idx)) {
336 T *entry = m_entries[idx];
346 if (m_map.MoveTo(&cursor, key)) {
348 arr.RemoveValue(idx);
349 if (arr.GetLength() == 0)
355 if (idx == m_entries.GetLength() - 1)
359 int prevIdx = int(m_entries.GetLength() - 1);
360 m_entries[idx] = m_entries.PopLast();
363 entry = m_entries[idx];
365 if (m_map.MoveTo(&cursor, key)) {
367 arr[arr.IndexOf(prevIdx)] = idx;
381 asUINT idx = m_entries.GetLength();
386 if (m_map.MoveTo(&cursor, key))
387 m_map.GetValue(cursor).PushLast(idx);
391 m_map.Insert(key, arr);
394 m_entries.PushLast(entry);
421 return idx < m_entries.GetLength();
429 int idx = int(m_entries.GetLength()) - 1;
430 asASSERT(idx == -1 || m_entries[idx]);
455 template<
class T,
class T2>
457 asUINT sz = m_table->m_entries.GetLength();
458 while (m_idx < sz && m_table->m_entries[m_idx] == 0)
464 template<
class T,
class T2>
466 asASSERT(m_table->CheckIdx(m_idx));
467 return m_table->m_entries[m_idx];
472 template<
class T,
class T2>
474 asASSERT(m_table->CheckIdx(m_idx));
475 return m_table->m_entries[m_idx];
480 template<
class T,
class T2>
491 template<
class T,
class T2>
493 return m_idx < m_table->m_entries.GetLength() && m_table->m_entries[m_idx] != 0;
498 template<
class T,
class T2>
500 asUINT sz = m_table->m_entries.GetLength();
502 while (m_idx < sz && m_table->m_entries[m_idx] == 0)
508 template<
class T,
class T2>
511 asUINT sz = m_table->m_entries.GetLength();
513 while (m_idx < sz && m_table->m_entries[m_idx] == 0)
519 template<
class T,
class T2>
528 #endif // AS_SYMBOLTABLE_H Definition: as_symboltable.h:76
Definition: as_namespace.h:39
Definition: as_symboltable.h:59
Definition: as_namespace.h:47
Definition: as_symboltable.h:69
Definition: as_string.h:41