Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10567 for code/branches/core7


Ignore:
Timestamp:
Sep 8, 2015, 4:16:28 PM (9 years ago)
Author:
landauf
Message:

added functions to use ObjectList<T> for any context

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/object/ObjectList.h

    r10467 r10567  
    7474            typedef ObjectListIterator<T> iterator;
    7575
     76            /// Returns the size of the list (for the root context)
     77            inline static size_t size()
     78            {   return size(Context::getRootContext());   }
    7679            /// Returns the size of the list
    77             inline static size_t size()
     80            inline static size_t size(Context* context)
    7881            {
    79                 return Context::getRootContext()->getObjectList<T>()->size();
     82                return context->getObjectList<T>()->size();
    8083            }
    8184
     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());   }
    8288            /// Returns an Iterator to the first element in the list.
    83             inline static ObjectListElement<T>* begin()
     89            inline static ObjectListElement<T>* begin(Context* context)
    8490            {
    85                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     91                ObjectListBase* list = context->getObjectList<T>();
    8692                return static_cast<ObjectListElement<T>*>(list->begin());
    8793            }
    8894
     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());   }
    8998            /// Returns an Iterator to the element after the last element in the list.
    90             inline static ObjectListElement<T>* end()
     99            inline static ObjectListElement<T>* end(Context* context)
    91100            {
    92                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     101                ObjectListBase* list = context->getObjectList<T>();
    93102                return static_cast<ObjectListElement<T>*>(list->end());
    94103            }
    95104
     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());   }
    96108            /// Returns an Iterator to the last element in the list.
    97             inline static ObjectListElement<T>* rbegin()
     109            inline static ObjectListElement<T>* rbegin(Context* context)
    98110            {
    99                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     111                ObjectListBase* list = context->getObjectList<T>();
    100112                return static_cast<ObjectListElement<T>*>(list->rbegin());
    101113            }
    102114
     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());   }
    103118            /// Returns an Iterator to the element before the first element in the list.
    104             inline static ObjectListElement<T>* rend()
     119            inline static ObjectListElement<T>* rend(Context* context)
    105120            {
    106                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     121                ObjectListBase* list = context->getObjectList<T>();
    107122                return static_cast<ObjectListElement<T>*>(list->rend());
    108123            }
Note: See TracChangeset for help on using the changeset viewer.