Changeset 10624 for code/trunk/src/libraries/core/object/ObjectList.h
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (10 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/libraries/core/object/ObjectList.h
r9667 r10624 47 47 #include "core/CorePrereqs.h" 48 48 49 #include <boost/static_assert.hpp> 50 #include <boost/type_traits/is_base_of.hpp> 51 49 52 #include "ObjectListBase.h" 50 53 #include "ObjectListIterator.h" … … 66 69 class ObjectList 67 70 { 71 BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value)); 72 68 73 public: 69 74 typedef ObjectListIterator<T> iterator; 70 75 76 /// Returns the size of the list (for the root context) 77 inline static size_t size() 78 { return size(Context::getRootContext()); } 71 79 /// Returns the size of the list 72 inline static size_t size( )80 inline static size_t size(Context* context) 73 81 { 74 return Context::getRootContext()->getObjectList<T>()->size();82 return context->getObjectList<T>()->size(); 75 83 } 76 84 85 /// Returns an Iterator to the first element in the list (for the root context). 86 inline static ObjectListElement<T>* begin() 87 { return begin(Context::getRootContext()); } 77 88 /// Returns an Iterator to the first element in the list. 78 inline static ObjectListElement<T>* begin( )89 inline static ObjectListElement<T>* begin(Context* context) 79 90 { 80 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();91 ObjectListBase* list = context->getObjectList<T>(); 81 92 return static_cast<ObjectListElement<T>*>(list->begin()); 82 93 } 83 94 95 /// Returns an Iterator to the element after the last element in the list (for the root context). 96 inline static ObjectListElement<T>* end() 97 { return end(Context::getRootContext()); } 84 98 /// Returns an Iterator to the element after the last element in the list. 85 inline static ObjectListElement<T>* end( )99 inline static ObjectListElement<T>* end(Context* context) 86 100 { 87 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();101 ObjectListBase* list = context->getObjectList<T>(); 88 102 return static_cast<ObjectListElement<T>*>(list->end()); 89 103 } 90 104 105 /// Returns an Iterator to the last element in the list (for the root context). 106 inline static ObjectListElement<T>* rbegin() 107 { return rbegin(Context::getRootContext()); } 91 108 /// Returns an Iterator to the last element in the list. 92 inline static ObjectListElement<T>* rbegin( )109 inline static ObjectListElement<T>* rbegin(Context* context) 93 110 { 94 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();111 ObjectListBase* list = context->getObjectList<T>(); 95 112 return static_cast<ObjectListElement<T>*>(list->rbegin()); 96 113 } 97 114 115 /// Returns an Iterator to the element before the first element in the list (for the root context). 116 inline static ObjectListElement<T>* rend() 117 { return rend(Context::getRootContext()); } 98 118 /// Returns an Iterator to the element before the first element in the list. 99 inline static ObjectListElement<T>* rend( )119 inline static ObjectListElement<T>* rend(Context* context) 100 120 { 101 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();121 ObjectListBase* list = context->getObjectList<T>(); 102 122 return static_cast<ObjectListElement<T>*>(list->rend()); 103 123 }
Note: See TracChangeset
for help on using the changeset viewer.