diff options
Diffstat (limited to 'src/lib/util/coretmpl.h')
-rw-r--r-- | src/lib/util/coretmpl.h | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index 703eba077da..afbd3dcf9a1 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -42,8 +42,8 @@ class simple_list public: // construction/destruction simple_list() - : m_head(NULL), - m_tail(NULL), + : m_head(nullptr), + m_tail(nullptr), m_count(0) { } virtual ~simple_list() { reset(); } @@ -56,7 +56,7 @@ public: // remove (free) all objects in the list, leaving an empty list void reset() { - while (m_head != NULL) + while (m_head != nullptr) remove(*m_head); } @@ -65,7 +65,7 @@ public: { object.m_next = m_head; m_head = &object; - if (m_tail == NULL) + if (m_tail == nullptr) m_tail = m_head; m_count++; return object; @@ -81,7 +81,7 @@ public: _ElementType *head = list.detach_all(); tail->m_next = m_head; m_head = head; - if (m_tail == NULL) + if (m_tail == nullptr) m_tail = tail; m_count += count; } @@ -89,8 +89,8 @@ public: // add the given object to the tail of the list _ElementType &append(_ElementType &object) { - object.m_next = NULL; - if (m_tail != NULL) + object.m_next = nullptr; + if (m_tail != nullptr) m_tail = m_tail->m_next = &object; else m_tail = m_head = &object; @@ -106,7 +106,7 @@ public: return; _ElementType *tail = list.last(); _ElementType *head = list.detach_all(); - if (m_tail != NULL) + if (m_tail != nullptr) m_tail->m_next = head; else m_head = head; @@ -117,7 +117,7 @@ public: // insert the given object after a particular object (NULL means prepend) _ElementType &insert_after(_ElementType &object, _ElementType *insert_after) { - if (insert_after == NULL) + if (insert_after == nullptr) return prepend(object); object.m_next = insert_after->m_next; insert_after->m_next = &object; @@ -130,9 +130,9 @@ public: // insert the given object before a particular object (NULL means append) _ElementType &insert_before(_ElementType &object, _ElementType *insert_before) { - if (insert_before == NULL) + if (insert_before == nullptr) return append(object); - for (_ElementType **curptr = &m_head; *curptr != NULL; curptr = &(*curptr)->m_next) + for (_ElementType **curptr = &m_head; *curptr != nullptr; curptr = &(*curptr)->m_next) if (*curptr == insert_before) { object.m_next = insert_before; @@ -148,11 +148,11 @@ public: // replace an item in the list at the same location, and remove it _ElementType &replace_and_remove(_ElementType &object, _ElementType &toreplace) { - _ElementType *prev = NULL; - for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next) + _ElementType *prev = nullptr; + for (_ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next) if (cur == &toreplace) { - if (prev != NULL) + if (prev != nullptr) prev->m_next = &object; else m_head = &object; @@ -169,12 +169,12 @@ public: _ElementType *detach_head() { _ElementType *result = m_head; - if (result != NULL) + if (result != nullptr) { m_head = result->m_next; m_count--; - if (m_head == NULL) - m_tail = NULL; + if (m_head == nullptr) + m_tail = nullptr; } return result; } @@ -182,11 +182,11 @@ public: // detach the given item from the list, but don't free its memory _ElementType &detach(_ElementType &object) { - _ElementType *prev = NULL; - for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next) + _ElementType *prev = nullptr; + for (_ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next) if (cur == &object) { - if (prev != NULL) + if (prev != nullptr) prev->m_next = object.m_next; else m_head = object.m_next; @@ -202,7 +202,7 @@ public: _ElementType *detach_all() { _ElementType *result = m_head; - m_head = m_tail = NULL; + m_head = m_tail = nullptr; m_count = 0; return result; } @@ -216,17 +216,17 @@ public: // find an object by index in the list _ElementType *find(int index) const { - for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next) + for (_ElementType *cur = m_head; cur != nullptr; cur = cur->m_next) if (index-- == 0) return cur; - return NULL; + return nullptr; } // return the index of the given object in the list int indexof(const _ElementType &object) const { int index = 0; - for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next) + for (_ElementType *cur = m_head; cur != nullptr; cur = cur->m_next) { if (cur == &object) return index; @@ -256,7 +256,7 @@ public: // construction/destruction simple_list_wrapper(_ObjectType *object) - : m_next(NULL), + : m_next(nullptr), m_object(object) { } // operators @@ -294,13 +294,13 @@ public: _ItemType *alloc() { _ItemType *result = m_freelist.detach_head(); - if (result == NULL) + if (result == nullptr) result = global_alloc(_ItemType); return result; } // reclaim an item by adding it to the free list - void reclaim(_ItemType *item) { if (item != NULL) m_freelist.append(*item); } + void reclaim(_ItemType *item) { if (item != nullptr) m_freelist.append(*item); } void reclaim(_ItemType &item) { m_freelist.append(item); } // reclaim all items from a list |