diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H index b80240310622e57cf2752076ecfbe31f1e95413f..42bfbacb27b6857ed58c300de535fcce4cffd261 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H @@ -144,7 +144,7 @@ public: void clear(); //- Transfer the contents of the argument into this DictionaryBase - // and annull the argument. + // and annul the argument. void transfer(DictionaryBase<IDLListType, T>&); // Member operators diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index a945859880a15c6da17ad2e5e7dba099ac3536ba..492d6a9e0f4ce6d206e6486955f027fea4684e43 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -287,7 +287,7 @@ public: void shrink(); //- Transfer the contents of the argument table into this table - // and annull the argument table. + // and annul the argument table. void transfer(HashTable<T, Key, Hash>&); //- Transfer contents to the Xfer container @@ -463,7 +463,7 @@ public: inline iterator operator++(int); }; - //- iterator set to the begining of the HashTable + //- iterator set to the beginning of the HashTable inline iterator begin(); diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index 09edf50c4644135cfa6d20330bf8d989894022a9..9806a138e00bdb60762d740651b32af853a8ee41 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -247,7 +247,7 @@ public: void clearStorage(); //- Transfer the contents of the argument table into this table - // and annull the argument table. + // and annul the argument table. void transfer(StaticHashTable<T, Key, Hash>&); //- Transfer contents to the Xfer container diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H index 20635fa53f944bedcaa4f240d05657a09782f2df..759d0c5dbe116705f4224e13a9fa8bb3d28d5de5 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H @@ -140,7 +140,7 @@ public: void clear(); //- Transfer the contents of the argument into this List - // and annull the argument list. + // and annul the argument list. void transfer(ILList<LListBase, T>&); diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index 0905f5543cbd7f272845f62d5d7d8afa0633b9ae..a5e99a63e4d49cc3752acfccebfedc659668f272 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -202,7 +202,7 @@ public: void clear(); //- Transfer the contents of the argument into this List - // and annull the argument list. + // and annul the argument list. void transfer(LList<LListBase, T>&); // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H index 333d916a65a4bbb84a0b75532cfcfaca28a0d463..c2e0250acd87cc74b59e96ae2a2b8e3932f01997 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H @@ -156,7 +156,7 @@ public: void clear(); //- Transfer the contents of the argument into this List - // and annull the argument list. + // and annul the argument list. void transfer(LPtrList<LListBase, T>&); diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 848b797b2eabaa5c2175eb978b6f7fb20460e409..beb3c625da675c128857cc5f5c68aff6ec51a421 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -172,7 +172,7 @@ public: inline void clear(); //- Transfer the contents of the argument into this List - // and annull the argument list. + // and annul the argument list. inline void transfer(DLListBase&); // STL iterator diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H index b5c957a537020bd534dcd5a7670b413606516201..b2958c9e558bc81a20770d4c521ecd0548f76ddf 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H @@ -157,7 +157,7 @@ public: inline void clear(); //- Transfer the contents of the argument into this List - // and annull the argument list. + // and annul the argument list. inline void transfer(SLListBase&); // STL iterator diff --git a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H index 5afd48d0f36c3b4ef11a09cf5bb8398df33d1338..1f761d9caf903a3d5bb50eba16130b01652baac3 100644 --- a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H +++ b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class BiIndirectList Declaration + Class BiIndirectList Declaration \*---------------------------------------------------------------------------*/ template<class T> @@ -82,11 +82,16 @@ public: // Access + //- Return the number of elements in the list inline label size() const; - inline bool empty() const; + + //- Return true if the list is empty (ie, size() is zero). + inline bool empty() const; inline const UList<T>& posList() const; inline const UList<T>& negList() const; + + //- Return the list addressing inline const List<label>& addressing() const; //- Calculate index given whether index is into posList or negList diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H index b2aad34d228e2115bbc78e013e69dd51b6e35659..e8ee819add1a4cc2cf706d6f425f44a0d74cf4f8 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H @@ -191,7 +191,7 @@ public: labelList sizes() const; //- Transfer the contents of the argument CompactListList - // into this CompactListList and annull the argument list. + // into this CompactListList and annul the argument list. void transfer(CompactListList<T, Container>&); //- Transfer the contents to the Xfer container diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 0e59184f668d5efa825f609be1875b73e4763df3..1d7285d86839e030810a46abfdb82bb75492d7af 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -154,6 +154,18 @@ public: // This can be used (with caution) when interfacing with C code. inline T* data(); + //- Return the first element of the list. + inline T& first(); + + //- Return first element of the list. + inline const T& first() const; + + //- Return the last element of the list. + inline T& last(); + + //- Return the last element of the list. + inline const T& last() const; + // Check diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index 1c3fe7131e6f179ad801a0151da2dd93d746c83e..ae762edb479254f43eb725a4b5589f1f6dcd987b 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -208,6 +208,34 @@ Foam::FixedList<T, Size>::data() } +template<class T, unsigned Size> +inline T& Foam::FixedList<T, Size>::first() +{ + return v_[0]; +} + + +template<class T, unsigned Size> +inline const T& Foam::FixedList<T, Size>::first() const +{ + return v_[0]; +} + + +template<class T, unsigned Size> +inline T& Foam::FixedList<T, Size>::last() +{ + return v_[Size-1]; +} + + +template<class T, unsigned Size> +inline const T& Foam::FixedList<T, Size>::last() const +{ + return v_[Size-1]; +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // element access diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H index cfdc03d7dc1fbc3d32a55020c423b8a5ce832ae2..a0d97af48ee42e49a22f9f7b5a1f360be07eed0a 100644 --- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H +++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class IndirectList Declaration + Class IndirectList Declaration \*---------------------------------------------------------------------------*/ template<class T> @@ -70,10 +70,28 @@ public: // Access + //- Return the number of elements in the list inline label size() const; - inline bool empty() const; + //- Return true if the list is empty (ie, size() is zero). + inline bool empty() const; + + //- Return the first element of the list. + inline T& first(); + + //- Return first element of the list. + inline const T& first() const; + + //- Return the last element of the list. + inline T& last(); + + //- Return the last element of the list. + inline const T& last() const; + + //- Return the complete list inline const UList<T>& completeList() const; + + //- Return the list addressing inline const List<label>& addressing() const; // Edit diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H index a1e2bf9a54e7018588b183d6f55614104e69bc95..47eedb733d1115cf0aba6d91830df8440090770a 100644 --- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H +++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H @@ -66,6 +66,34 @@ inline bool Foam::IndirectList<T>::empty() const } +template<class T> +inline T& Foam::IndirectList<T>::first() +{ + return completeList_[addressing_.first()]; +} + + +template<class T> +inline const T& Foam::IndirectList<T>::first() const +{ + return completeList_[addressing_.first()]; +} + + +template<class T> +inline T& Foam::IndirectList<T>::last() +{ + return completeList_[addressing_.last()]; +} + + +template<class T> +inline const T& Foam::IndirectList<T>::last() const +{ + return completeList_[addressing_.last()]; +} + + template<class T> inline const Foam::UList<T>& Foam::IndirectList<T>::completeList() const { diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index fb6d9a0678929e05f12888dc97361f578aadc32e..4158043b083ddcd28d799d03979dbe6f842bdbc0 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -404,7 +404,7 @@ void Foam::List<T>::clear() // Transfer the contents of the argument List into this List -// and anull the argument list +// and annul the argument list template<class T> void Foam::List<T>::transfer(List<T>& a) { @@ -418,7 +418,7 @@ void Foam::List<T>::transfer(List<T>& a) // Transfer the contents of the argument DynamicList into this List -// and anull the argument list +// and annul the argument list template<class T> template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a) @@ -431,7 +431,7 @@ void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a) // Transfer the contents of the argument SortableList into this List -// and anull the argument list +// and annul the argument list template<class T> void Foam::List<T>::transfer(SortableList<T>& a) { diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 7e623f6560f8008fdedbaa0d132651d8c0c2d0f4..5fec41ef4d7a9a0ecdacda2916cd9bef02f1c171 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -188,16 +188,16 @@ public: inline void append(const UIndirectList<T>&); //- Transfer the contents of the argument List into this list - // and annull the argument list. + // and annul the argument list. void transfer(List<T>&); //- Transfer the contents of the argument List into this list - // and annull the argument list. + // and annul the argument list. template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&); //- Transfer the contents of the argument List into this list - // and annull the argument list. + // and annul the argument list. void transfer(SortableList<T>&); //- Transfer contents to the Xfer container diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index 82ac19fc0e532305100010cb82cb3fab17bc3899..78c7306b6e477d7f8a5482963b17f37c68649a7c 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -253,7 +253,7 @@ public: inline void shrink(); //- Transfer the contents of the argument list into this list - // and annull the argument list. + // and annul the argument list. inline void transfer(PackedList<nBits>&); //- Transfer contents to the Xfer container diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H index 3f3e6d8fe6c284e32d1683ca6ab0010854c73b40..fdefbf597c6d7c5b5cf3d4fb0e251927b83b1076 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H @@ -29,8 +29,8 @@ Description A templated 1D list of pointers to objects of type \<T\>, where the size of the array is known and used for subscript bounds checking, etc. - The element operator [] returns a reference to the object - rather than to the pointer. + The element operator [] returns a reference to the object rather than a + pointer. SourceFiles PtrList.C @@ -119,7 +119,7 @@ public: //- Null Constructor. PtrList(); - //- Construct with length specified. + //- Construct with size specified. explicit PtrList(const label); //- Copy constructor. @@ -130,7 +130,7 @@ public: PtrList(const PtrList<T>&, const CloneArg&); //- Construct by transferring the parameter contents - PtrList(const Xfer<PtrList<T> >&); + PtrList(const Xfer< PtrList<T> >&); //- Construct as copy or re-use as specified. PtrList(PtrList<T>&, bool reUse); @@ -161,6 +161,17 @@ public: //- Return true if the PtrList is empty (ie, size() is zero). inline bool empty() const; + //- Return reference to the first element of the list. + inline T& first(); + + //- Return reference to first element of the list. + inline const T& first() const; + + //- Return reference to the last element of the list. + inline T& last(); + + //- Return reference to the last element of the list. + inline const T& last() const; // Edit @@ -181,11 +192,11 @@ public: void clear(); //- Transfer the contents of the argument PtrList into this PtrList - // and annull the argument list. + // and annul the argument list. void transfer(PtrList<T>&); //- Transfer contents to the Xfer container - inline Xfer<PtrList<T> > xfer(); + inline Xfer< PtrList<T> > xfer(); //- Is element set inline bool set(const label) const; diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H index d450cdd09fe7107d975d338031f066878be7fca1..72cb24f78dd1226410738f7b182bd17df69039b3 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H @@ -45,6 +45,34 @@ inline bool Foam::PtrList<T>::empty() const } +template<class T> +inline T& Foam::PtrList<T>::first() +{ + return this->operator[](0); +} + + +template<class T> +inline const T& Foam::PtrList<T>::first() const +{ + return this->operator[](0); +} + + +template<class T> +inline T& Foam::PtrList<T>::last() +{ + return this->operator[](this->size()-1); +} + + +template<class T> +inline const T& Foam::PtrList<T>::last() const +{ + return this->operator[](this->size()-1); +} + + template<class T> inline void Foam::PtrList<T>::resize(const label newSize) { @@ -63,9 +91,7 @@ template<class T> inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, T* ptr) { autoPtr<T> old(ptrs_[i]); - ptrs_[i] = ptr; - return old; } @@ -102,7 +128,7 @@ inline Foam::Xfer<Foam::PtrList<T> > Foam::PtrList<T>::xfer() // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T> -const T& Foam::PtrList<T>::operator[](const label i) const +inline const T& Foam::PtrList<T>::operator[](const label i) const { if (!ptrs_[i]) { @@ -116,7 +142,7 @@ const T& Foam::PtrList<T>::operator[](const label i) const template<class T> -T& Foam::PtrList<T>::operator[](const label i) +inline T& Foam::PtrList<T>::operator[](const label i) { if (!ptrs_[i]) { @@ -130,7 +156,7 @@ T& Foam::PtrList<T>::operator[](const label i) template<class T> -const T* Foam::PtrList<T>::operator()(const label i) const +inline const T* Foam::PtrList<T>::operator()(const label i) const { return ptrs_[i]; } @@ -297,5 +323,4 @@ Foam::PtrList<T>::end() } - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H index 0219e02af72861fb2c92b001b498f6ff1fb68b18..61ec6bf2d144f87a3a3aab68108a75463e07ff47 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H @@ -27,6 +27,7 @@ Class Description A List with indirect addressing. + Like IndirectList but does not store addressing. SourceFiles @@ -73,8 +74,24 @@ public: // Access + //- Return the number of elements in the list inline label size() const; - inline bool empty() const; + + //- Return true if the list is empty (ie, size() is zero). + inline bool empty() const; + + //- Return the first element of the list. + inline T& first(); + + //- Return first element of the list. + inline const T& first() const; + + //- Return the last element of the list. + inline T& last(); + + //- Return the last element of the list. + inline const T& last() const; + inline const UList<T>& completeList() const; inline const List<label>& addressing() const; diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H index ff8b3ebbd6d0ff9146cc259baf09bb0004218bb9..e8e7565ed1318a61a8a27a7d0a66b47065387eaf 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H @@ -54,6 +54,34 @@ inline bool Foam::UIndirectList<T>::empty() const } +template<class T> +inline T& Foam::UIndirectList<T>::first() +{ + return completeList_[addressing_.first()]; +} + + +template<class T> +inline const T& Foam::UIndirectList<T>::first() const +{ + return completeList_[addressing_.first()]; +} + + +template<class T> +inline T& Foam::UIndirectList<T>::last() +{ + return completeList_[addressing_.last()]; +} + + +template<class T> +inline const T& Foam::UIndirectList<T>::last() const +{ + return completeList_[addressing_.last()]; +} + + template<class T> inline const Foam::UList<T>& Foam::UIndirectList<T>::completeList() const { diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index b829c99ea5f69cbe6233b827c972117437d14b4e..b9332d04c2e86d37dcefe93b34542a9945569934 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -132,7 +132,7 @@ public: inline label fcIndex(const label i) const; //- Return the reverse circular index, i.e. the previous index - // which returns to the last at the begining of the list + // which returns to the last at the beginning of the list inline label rcIndex(const label i) const; //- Return the binary size in number of characters of the UList @@ -151,6 +151,18 @@ public: // This can be used (with caution) when interfacing with C code. inline T* data(); + //- Return the first element of the list. + inline T& first(); + + //- Return first element of the list. + inline const T& first() const; + + //- Return the last element of the list. + inline T& last(); + + //- Return the last element of the list. + inline const T& last() const; + // Check @@ -184,12 +196,6 @@ public: // an out-of-range element returns false without any ill-effects inline const T& operator[](const label) const; - //- Return last element of UList. - inline T& last(); - - //- Return last element of UList. - inline const T& last() const; - //- Allow cast to a const List<T>& inline operator const Foam::List<T>&() const; diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index aa7d396f105c2387b25120113f81e6e26dda8759..fb68f29ee86ed0575e541b2aaa4b0197d0110d1e 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -114,6 +114,20 @@ inline void Foam::UList<T>::checkIndex(const label i) const } +template<class T> +inline T& Foam::UList<T>::first() +{ + return this->operator[](0); +} + + +template<class T> +inline const T& Foam::UList<T>::first() const +{ + return this->operator[](0); +} + + template<class T> inline T& Foam::UList<T>::last() { diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C index bed0214749efe46fecb7de60e3e063c612fbf7d7..93b7a514c6653282ccafd5d9169b9452ac36374e 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C @@ -93,8 +93,6 @@ void Foam::UPtrList<T>::clear() } -// Transfer the contents of the argument List into this List -// and anull the argument list template<class T> void Foam::UPtrList<T>::transfer(UPtrList<T>& a) { diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H index a334e812543688364dbbde8b6754e4fff2542286..eaf70c3b05b1fcfbce88de1af119ef12811f3ec7 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H @@ -26,8 +26,8 @@ Class Foam::UPtrList Description - A 1D array of pointers to objects of type \<T\>, where the size of the - array is known and used for subscript bounds checking, etc. + A templated 1D list of pointers to objects of type \<T\>, where the + size of the array is known and used for subscript bounds checking, etc. The element operator [] returns a reference to the object rather than a pointer. Storage is not allocated during construction or use but is @@ -107,11 +107,11 @@ public: //- Null Constructor. UPtrList(); - //- Construct with length specified. + //- Construct with size specified. explicit UPtrList(const label); //- Construct by transferring the parameter contents - UPtrList(const Xfer<UPtrList<T> >&); + UPtrList(const Xfer< UPtrList<T> >&); //- Construct as copy or re-use as specified. UPtrList(UPtrList<T>&, bool reUse); @@ -127,6 +127,18 @@ public: //- Return true if the UPtrList is empty (ie, size() is zero). inline bool empty() const; + //- Return reference to the first element of the list. + inline T& first(); + + //- Return reference to first element of the list. + inline const T& first() const; + + //- Return reference to the last element of the list. + inline T& last(); + + //- Return reference to the last element of the list. + inline const T& last() const; + // Edit @@ -144,11 +156,11 @@ public: void clear(); //- Transfer the contents of the argument UPtrList into this - // UPtrList and annull the argument list. + // UPtrList and annul the argument list. void transfer(UPtrList<T>&); //- Transfer contents to the Xfer container - inline Xfer<UPtrList<T> > xfer(); + inline Xfer< UPtrList<T> > xfer(); //- Is element set inline bool set(const label) const; diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H index 859f54fce5f7d45b2cb278be640db627183d7ceb..1d73bc920da2c71acc53b7653ed696aeffaa0cad 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H @@ -42,6 +42,34 @@ inline bool Foam::UPtrList<T>::empty() const } +template<class T> +inline T& Foam::UPtrList<T>::first() +{ + return this->operator[](0); +} + + +template<class T> +inline const T& Foam::UPtrList<T>::first() const +{ + return this->operator[](0); +} + + +template<class T> +inline T& Foam::UPtrList<T>::last() +{ + return this->operator[](this->size()-1); +} + + +template<class T> +inline const T& Foam::UPtrList<T>::last() const +{ + return this->operator[](this->size()-1); +} + + template<class T> inline void Foam::UPtrList<T>::resize(const label newSize) { @@ -55,6 +83,7 @@ inline bool Foam::UPtrList<T>::set(const label i) const return ptrs_[i] != NULL; } + template<class T> inline T* Foam::UPtrList<T>::set(const label i, T* ptr) { @@ -63,6 +92,7 @@ inline T* Foam::UPtrList<T>::set(const label i, T* ptr) return old; } + template<class T> inline Foam::Xfer<Foam::UPtrList<T> > Foam::UPtrList<T>::xfer() { @@ -73,7 +103,7 @@ inline Foam::Xfer<Foam::UPtrList<T> > Foam::UPtrList<T>::xfer() // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T> -const T& Foam::UPtrList<T>::operator[](const label i) const +inline const T& Foam::UPtrList<T>::operator[](const label i) const { if (!ptrs_[i]) { @@ -87,7 +117,7 @@ const T& Foam::UPtrList<T>::operator[](const label i) const template<class T> -T& Foam::UPtrList<T>::operator[](const label i) +inline T& Foam::UPtrList<T>::operator[](const label i) { if (!ptrs_[i]) { @@ -101,7 +131,7 @@ T& Foam::UPtrList<T>::operator[](const label i) template<class T> -const T* Foam::UPtrList<T>::operator()(const label i) const +inline const T* Foam::UPtrList<T>::operator()(const label i) const { return ptrs_[i]; }