Changeset 10920 for code/branches/cpp11_v2/src/libraries/core/object
- Timestamp:
- Dec 6, 2015, 2:51:14 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/core/object
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/object/ObjectList.h
r10774 r10920 71 71 typedef ObjectListIterator<T> iterator; 72 72 73 /// Returns the size of the list (for the root context) 74 inline static size_t size() 75 { return size(Context::getRootContext()); } 73 ObjectList() : ObjectList(Context::getRootContext()) {} 74 ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {} 75 ObjectList(ObjectListBase* list) : list_(list) {} 76 76 77 /// Returns the size of the list 77 inline static size_t size(Context* context) 78 { 79 return context->getObjectList<T>()->size(); 80 } 78 inline size_t size() 79 { return this->list_->size(); } 81 80 82 /// Returns an Iterator to the first element in the list (for the root context).83 inline static ObjectListIterator<T> begin()84 { return begin(Context::getRootContext()); }85 81 /// Returns an Iterator to the first element in the list. 86 inline static ObjectListIterator<T> begin(Context* context)87 { 88 ObjectListBase* list = context->getObjectList<T>();89 return static_cast<ObjectListElement<T>*>(list->begin());90 }82 inline ObjectListIterator<T> begin() 83 { return static_cast<ObjectListElement<T>*>(this->list_->begin()); } 84 /// Returns an Iterator to the element after the last element in the list. 85 inline ObjectListIterator<T> end() 86 { return static_cast<ObjectListElement<T>*>(this->list_->end()); } 91 87 92 /// Returns an Iterator to the element after the last element in the list (for the root context). 93 inline static ObjectListIterator<T> end() 94 { return end(Context::getRootContext()); } 95 /// Returns an Iterator to the element after the last element in the list. 96 inline static ObjectListIterator<T> end(Context* context) 97 { 98 ObjectListBase* list = context->getObjectList<T>(); 99 return static_cast<ObjectListElement<T>*>(list->end()); 100 } 88 /// Returns an Iterator to the last element in the list. 89 inline ObjectListIterator<T> rbegin() 90 { return static_cast<ObjectListElement<T>*>(this->list_->rbegin()); } 91 /// Returns an Iterator to the element before the first element in the list. 92 inline ObjectListIterator<T> rend() 93 { return static_cast<ObjectListElement<T>*>(this->list_->rend()); } 101 94 102 /// Returns an Iterator to the last element in the list (for the root context). 103 inline static ObjectListIterator<T> rbegin() 104 { return rbegin(Context::getRootContext()); } 105 /// Returns an Iterator to the last element in the list. 106 inline static ObjectListIterator<T> rbegin(Context* context) 107 { 108 ObjectListBase* list = context->getObjectList<T>(); 109 return static_cast<ObjectListElement<T>*>(list->rbegin()); 110 } 111 112 /// Returns an Iterator to the element before the first element in the list (for the root context). 113 inline static ObjectListIterator<T> rend() 114 { return rend(Context::getRootContext()); } 115 /// Returns an Iterator to the element before the first element in the list. 116 inline static ObjectListIterator<T> rend(Context* context) 117 { 118 ObjectListBase* list = context->getObjectList<T>(); 119 return static_cast<ObjectListElement<T>*>(list->rend()); 120 } 95 private: 96 ObjectListBase* list_; 121 97 }; 122 98 } -
code/branches/cpp11_v2/src/libraries/core/object/ObjectListIterator.h
r10769 r10920 41 41 Usage: 42 42 @code 43 for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it) 43 ObjectList<myClass> list; 44 for (ObjectListIterator<myClass> it = list.begin(); it != list.end(); ++it) 44 45 { 45 46 it->someFunction(...);
Note: See TracChangeset
for help on using the changeset viewer.