wlan_bearer/wlanldd/wlan_common/osa_common/inc/osalist.inl
changeset 19 629e60dfa279
parent 0 c40eb8fe8501
equal deleted inserted replaced
17:41a8eba36f74 19:629e60dfa279
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 * Description:   inline implementation of list
    14 * Description:   inline implementation of list
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 5 %
    19 * %version: 6 %
    20 */
    20 */
    21 
    21 
    22 #include <wlanosa.h>
    22 #include <wlanosa.h>
    23 #include "osa_includeme.h"
    23 #include "osa_includeme.h"
    24 
    24 
    35 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    36 // 
    36 // 
    37 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    38 //
    38 //
    39 template<class T>
    39 template<class T>
    40 inline list<T>::iterator list<T>::begin()
    40 inline typename list<T>::iterator list<T>::begin()
    41     {
    41     {
    42     // for empty ranges begin() == end()
    42     // for empty ranges begin() == end()
    43     return ( !(empty()) ? list_iterator<Node, T>( iFirst ) : end() );
    43     return ( !(empty()) ? list_iterator<Node, T>( iFirst ) : end() );
    44     }
    44     }
    45 
    45 
    46 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    47 // 
    47 // 
    48 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    49 //
    49 //
    50 template<class T>
    50 template<class T>
    51 inline list<T>::const_iterator list<T>::begin() const
    51 inline typename list<T>::const_iterator list<T>::begin() const
    52     {
    52     {
    53     // for empty ranges begin() == end()
    53     // for empty ranges begin() == end()
    54     return ( !(empty()) ? list_iterator<Node, T>( iFirst ) : end() );
    54     return ( !(empty()) ? list_iterator<Node, T>( iFirst ) : end() );
    55     }
    55     }
    56 
    56 
    57 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    58 // 
    58 // 
    59 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    60 //
    60 //
    61 template<class T>
    61 template<class T>
    62 inline list<T>::iterator list<T>::end()
    62 inline typename list<T>::iterator list<T>::end()
    63     {
    63     {
    64     return list_iterator<Node, T>();
    64     return list_iterator<Node, T>();
    65     }
    65     }
    66 
    66 
    67 // -----------------------------------------------------------------------------
    67 // -----------------------------------------------------------------------------
    68 // 
    68 // 
    69 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
    70 //
    70 //
    71 template<class T>
    71 template<class T>
    72 inline list<T>::const_iterator list<T>::end() const
    72 inline typename list<T>::const_iterator list<T>::end() const
    73     {
    73     {
    74     return list_iterator<Node, T>();
    74     return list_iterator<Node, T>();
    75     }
    75     }
    76 
    76 
    77 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    78 // 
    78 // 
    79 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    80 //
    80 //
    81 template<class T>
    81 template<class T>
    82 inline list<T>::size_type list<T>::size() const
    82 inline typename list<T>::size_type list<T>::size() const
    83     {
    83     {
    84     return iNumOfElems;
    84     return iNumOfElems;
    85     }
    85     }
    86 
    86 
    87 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    97 // -----------------------------------------------------------------------------
    97 // -----------------------------------------------------------------------------
    98 // 
    98 // 
    99 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
   100 //
   100 //
   101 template<class T>
   101 template<class T>
   102 inline list<T>::reference list<T>::front()
   102 inline typename list<T>::reference list<T>::front()
   103     {
   103     {
   104     // front() for empty sequence is undefined so assert
   104     // front() for empty sequence is undefined so assert
   105     MWlanOsa::Assert( 
   105     MWlanOsa::Assert( 
   106         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   106         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   107     return iFirst->iElem;
   107     return iFirst->iElem;
   110 // -----------------------------------------------------------------------------
   110 // -----------------------------------------------------------------------------
   111 // 
   111 // 
   112 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   113 //
   113 //
   114 template<class T>
   114 template<class T>
   115 inline list<T>::const_reference list<T>::front()  const
   115 inline typename list<T>::const_reference list<T>::front()  const
   116     {
   116     {
   117     // front() for empty sequence is undefined so assert
   117     // front() for empty sequence is undefined so assert
   118     MWlanOsa::Assert( 
   118     MWlanOsa::Assert( 
   119         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   119         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   120     return iFirst->iElem;
   120     return iFirst->iElem;
   123 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   124 // 
   124 // 
   125 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   126 //
   126 //
   127 template<class T>
   127 template<class T>
   128 inline list<T>::reference list<T>::back()
   128 inline typename list<T>::reference list<T>::back()
   129     {
   129     {
   130     // back() for empty sequence is undefined so assert
   130     // back() for empty sequence is undefined so assert
   131     MWlanOsa::Assert( 
   131     MWlanOsa::Assert( 
   132         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   132         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   133     return iLast->iElem;
   133     return iLast->iElem;
   136 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   137 // 
   137 // 
   138 // -----------------------------------------------------------------------------
   138 // -----------------------------------------------------------------------------
   139 //
   139 //
   140 template<class T>
   140 template<class T>
   141 inline list<T>::const_reference list<T>::back() const
   141 inline typename list<T>::const_reference list<T>::back() const
   142     {
   142     {
   143     // back() for empty sequence is undefined so assert
   143     // back() for empty sequence is undefined so assert
   144     MWlanOsa::Assert( 
   144     MWlanOsa::Assert( 
   145         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   145         reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, size() );
   146     return iLast->iElem;
   146     return iLast->iElem;
   302 // -----------------------------------------------------------------------------
   302 // -----------------------------------------------------------------------------
   303 // 
   303 // 
   304 // -----------------------------------------------------------------------------
   304 // -----------------------------------------------------------------------------
   305 //
   305 //
   306 template<class T>
   306 template<class T>
   307 inline list<T>::iterator list<T>::insert( iterator aPos, const T& aElem )
   307 inline typename list<T>::iterator list<T>::insert( 
       
   308     iterator aPos, 
       
   309     const T& aElem )
   308     {
   310     {
   309     // allocate a new node for the element
   311     // allocate a new node for the element
   310     Node* node = new Node( aElem );
   312     Node* node = new Node( aElem );
   311 
   313 
   312     if ( node )
   314     if ( node )
   353 // -----------------------------------------------------------------------------
   355 // -----------------------------------------------------------------------------
   354 // 
   356 // 
   355 // -----------------------------------------------------------------------------
   357 // -----------------------------------------------------------------------------
   356 //
   358 //
   357 template<class T>
   359 template<class T>
   358 inline list<T>::iterator list<T>::erase( iterator aPos )
   360 inline typename list<T>::iterator list<T>::erase( iterator aPos )
   359     {
   361     {
   360     // extract node to be erased
   362     // extract node to be erased
   361     Node* node = aPos();
   363     Node* node = aPos();
   362 
   364 
   363     if ( node->iNext )
   365     if ( node->iNext )