Kaynağa Gözat

Initialize IDs in ctor and add begin()

Daniele Bartolini 12 yıl önce
ebeveyn
işleme
2948124fcc
1 değiştirilmiş dosya ile 13 ekleme ve 0 silme
  1. 13 0
      engine/core/containers/IdTable.h

+ 13 - 0
engine/core/containers/IdTable.h

@@ -59,6 +59,8 @@ public:
 	/// Returns whether the table has the specified @a id
 	/// Returns whether the table has the specified @a id
 	bool			has(Id id) const;
 	bool			has(Id id) const;
 
 
+	const Id*		begin() const;
+
 private:
 private:
 
 
 	// Returns the next available unique id.
 	// Returns the next available unique id.
@@ -86,6 +88,10 @@ template <uint32_t MAX_NUM_ID>
 inline IdTable<MAX_NUM_ID>::IdTable()
 inline IdTable<MAX_NUM_ID>::IdTable()
 	: m_freelist(MAX_NUM_ID), m_last_index(0), m_next_id(0)
 	: m_freelist(MAX_NUM_ID), m_last_index(0), m_next_id(0)
 {
 {
+	for (uint32_t i = 0; i < MAX_NUM_ID; i++)
+	{
+		m_ids[i].id = INVALID_ID;
+	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -130,6 +136,13 @@ inline bool IdTable<MAX_NUM_ID>::has(Id id) const
 	return id.index < MAX_NUM_ID && m_ids[id.index].id == id.id;
 	return id.index < MAX_NUM_ID && m_ids[id.index].id == id.id;
 }
 }
 
 
+//-----------------------------------------------------------------------------
+template <uint32_t MAX_NUM_ID>
+inline const Id* IdTable<MAX_NUM_ID>::begin() const
+{
+	return m_ids;
+}
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <uint32_t MAX_NUM_ID>
 template <uint32_t MAX_NUM_ID>
 inline uint16_t IdTable<MAX_NUM_ID>::next_id()
 inline uint16_t IdTable<MAX_NUM_ID>::next_id()