Items in shared memory

This commit is contained in:
KimLS
2013-02-20 22:36:30 -08:00
parent 0115b18e67
commit 3e9c2a06a3
11 changed files with 496 additions and 332 deletions
+8 -3
View File
@@ -49,7 +49,7 @@ namespace EQEmu {
size_ = size;
byte *ptr = data;
*reinterpret_cast<key_type*>(ptr) = max_element_id;
*reinterpret_cast<key_type*>(ptr) = max_element_id + 1;
offset_count_ = max_element_id + 1;
ptr += sizeof(key_type);
@@ -62,8 +62,8 @@ namespace EQEmu {
ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr);
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * max_element_id);
ptr += sizeof(key_type) * max_element_id;
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1));
ptr += sizeof(key_type) * (max_element_id + 1);
elements_ = reinterpret_cast<value_type*>(ptr);
}
@@ -151,6 +151,11 @@ namespace EQEmu {
size_type max_size() const {
return max_elements_;
}
//! Returns the maximum key one can use with the set.
key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0;
}
/*!
Retrieve value operator