mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -56,7 +56,6 @@ int main(int argc, char *argv[])
|
||||
Info<< "element:" << *iter << endl;
|
||||
}
|
||||
|
||||
|
||||
Info<< nl << "And again using the same STL iterator: " << nl << endl;
|
||||
|
||||
forAllIters(myList, iter)
|
||||
|
||||
@ -36,14 +36,9 @@ void printTable(const HashPtrTable<T>& table)
|
||||
{
|
||||
Info<< table.size() << nl << "(" << nl;
|
||||
|
||||
for
|
||||
(
|
||||
typename HashPtrTable<T>::const_iterator iter = table.cbegin();
|
||||
iter != table.cend();
|
||||
++iter
|
||||
)
|
||||
forAllConstIters(table, iter)
|
||||
{
|
||||
const T* ptr = *iter;
|
||||
const T* ptr = iter.object();
|
||||
Info<< iter.key() << " = ";
|
||||
if (ptr)
|
||||
{
|
||||
@ -57,6 +52,22 @@ void printTable(const HashPtrTable<T>& table)
|
||||
}
|
||||
|
||||
Info<< ")" << endl;
|
||||
|
||||
// Values only, with for-range
|
||||
Info<< "values (";
|
||||
for (auto val : table)
|
||||
{
|
||||
Info<< ' ';
|
||||
if (val)
|
||||
{
|
||||
Info<< *val;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "nullptr";
|
||||
}
|
||||
}
|
||||
Info<< " )" << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +79,9 @@ int main()
|
||||
HashPtrTable<double> myTable;
|
||||
myTable.insert("abc", new double(42.1));
|
||||
myTable.insert("def", nullptr);
|
||||
myTable.insert("ghi", new double(3.14159));
|
||||
myTable.insert("pi", new double(3.14159));
|
||||
myTable.insert("natlog", new double(2.718282));
|
||||
myTable.insert("sqrt2", new double(1.414214));
|
||||
|
||||
// Info<< myTable << endl;
|
||||
printTable(myTable);
|
||||
@ -79,8 +92,20 @@ int main()
|
||||
printTable(copy);
|
||||
Info<< copy << endl;
|
||||
|
||||
Info<<"\nerase some existing and non-existing entries" << nl;
|
||||
|
||||
auto iter = myTable.find("pi");
|
||||
myTable.erase(iter);
|
||||
|
||||
iter = myTable.find("unknownKey");
|
||||
myTable.erase(iter);
|
||||
|
||||
myTable.erase("abc");
|
||||
myTable.erase("unknownKey");
|
||||
|
||||
printTable(myTable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -197,8 +197,12 @@ int main(int argc, char *argv[])
|
||||
Info<< "setD has no 11" << endl;
|
||||
}
|
||||
|
||||
Info<< "setB : " << flatOutput(setB) << endl;
|
||||
Info<< "setD : " << flatOutput(setD) << endl;
|
||||
|
||||
setD -= setB;
|
||||
Info<< "setD -= setB : " << flatOutput(setD) << endl;
|
||||
|
||||
// This should not work (yet?)
|
||||
// setD[12] = true;
|
||||
|
||||
|
||||
@ -25,6 +25,9 @@ License
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "List.H"
|
||||
#include "SortableList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "FlatOutput.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
@ -163,15 +166,15 @@ int main()
|
||||
<< "\ntable2" << table2 << nl;
|
||||
|
||||
|
||||
Info<< "\ntable3" << table3
|
||||
<< "\nclearStorage table3 ... ";
|
||||
table3.clearStorage();
|
||||
Info<< table3 << nl;
|
||||
Info<< "\ntable3" << table2
|
||||
<< "\nclearStorage table2 ... ";
|
||||
table2.clearStorage();
|
||||
Info<< table2 << nl;
|
||||
|
||||
table1 =
|
||||
{
|
||||
{"aca", 3.0},
|
||||
{"aaw", 6.0},
|
||||
{"abc", 3.0},
|
||||
{"def", 6.0},
|
||||
{"acr", 8.0},
|
||||
{"aec", 10.0}
|
||||
};
|
||||
@ -193,7 +196,43 @@ int main()
|
||||
// These do not yet work. Issues resolving the distance.
|
||||
//
|
||||
// List<scalar> table1vals(table1.begin(), table1.end());
|
||||
// wordList table1keys(table1.begin(), table1.end());
|
||||
|
||||
{
|
||||
Info<<"distance/size: "
|
||||
<< std::distance(table1.begin(), table1.end())
|
||||
<< "/" << table1.size()
|
||||
<< " and "
|
||||
<< std::distance(table1.keys().begin(), table1.keys().end())
|
||||
<< "/" << table1.keys().size()
|
||||
<< nl;
|
||||
|
||||
SortableList<word> sortKeys
|
||||
// DynamicList<word> sortKeys
|
||||
(
|
||||
table1.keys().begin(),
|
||||
table1.keys().end()
|
||||
);
|
||||
Info<<"sortKeys: " << flatOutput(sortKeys) << nl;
|
||||
}
|
||||
|
||||
Info<< "\nFrom table1: " << flatOutput(table1.sortedToc()) << nl
|
||||
<< "retain keys: " << flatOutput(table3.sortedToc()) << nl;
|
||||
|
||||
table1.retain(table3);
|
||||
Info<< "-> " << flatOutput(table1.sortedToc()) << nl;
|
||||
|
||||
Info<< "Lookup non-existent" << nl;
|
||||
|
||||
Info<< table1.lookup("missing-const", 1.2345e+6)
|
||||
<< " // const-access" << nl;
|
||||
|
||||
Info<< table1("missing-inadvertent", 3.14159)
|
||||
<< " // (inadvertent?) non-const access" << nl;
|
||||
|
||||
Info<< table1("missing-autovivify")
|
||||
<< " // Known auto-vivification (non-const access)" << nl;
|
||||
|
||||
Info<<"\ntable1: " << table1 << endl;
|
||||
|
||||
Info<< "\nDone\n";
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ See also
|
||||
#include "vector.H"
|
||||
|
||||
#include "labelRange.H"
|
||||
#include "scalarList.H"
|
||||
#include "ListOps.H"
|
||||
#include "SubList.H"
|
||||
|
||||
@ -144,6 +145,18 @@ int main(int argc, char *argv[])
|
||||
|
||||
labelList longLabelList = identity(15);
|
||||
|
||||
// This does not work:
|
||||
// scalarList slist = identity(15);
|
||||
//
|
||||
// More writing, but does work:
|
||||
scalarList slist
|
||||
(
|
||||
labelRange::null.begin(),
|
||||
labelRange::identity(15).end()
|
||||
);
|
||||
|
||||
Info<<"scalar identity:" << flatOutput(slist) << endl;
|
||||
|
||||
Info<< "labels (contiguous=" << contiguous<label>() << ")" << nl;
|
||||
|
||||
Info<< "normal: " << longLabelList << nl;
|
||||
@ -220,7 +233,32 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Info<< "sub-sorted: " << flatOutput(longLabelList) << nl;
|
||||
|
||||
// Info<<"Slice=" << longLabelList[labelRange(23,5)] << nl;
|
||||
// construct from a label-range
|
||||
labelRange range(25,15);
|
||||
|
||||
labelList ident(range.begin(), range.end());
|
||||
Info<<"range-list (label)=" << ident << nl;
|
||||
|
||||
List<scalar> sident(range.begin(), range.end());
|
||||
Info<<"range-list (scalar)=" << sident << nl;
|
||||
|
||||
// Sub-ranges also work
|
||||
List<scalar> sident2(range(3), range(10));
|
||||
Info<<"range-list (scalar)=" << sident2 << nl;
|
||||
|
||||
// VERY BAD IDEA: List<scalar> sident3(range(10), range(3));
|
||||
|
||||
// This doesn't work, and don't know what it should do anyhow
|
||||
// List<vector> vident(range.begin(), range.end());
|
||||
// Info<<"range-list (vector)=" << vident << nl;
|
||||
|
||||
// Even weird things like this
|
||||
List<scalar> sident4
|
||||
(
|
||||
labelRange().begin(),
|
||||
labelRange::identity(8).end()
|
||||
);
|
||||
Info<<"range-list (scalar)=" << sident4 << nl;
|
||||
}
|
||||
|
||||
wordReList reLst;
|
||||
|
||||
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
|
||||
Info<<"test sorting" << endl;
|
||||
DynamicList<labelRange> list1(10);
|
||||
list1.append(labelRange(25, 8));
|
||||
list1.append(labelRange(0, 10));
|
||||
list1.append(labelRange::identity(8));
|
||||
list1.append(labelRange(15, 5));
|
||||
list1.append(labelRange(50, -10));
|
||||
|
||||
|
||||
@ -72,30 +72,44 @@ Foam::HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
||||
template<class T, class Key, class Hash>
|
||||
T* Foam::HashPtrTable<T, Key, Hash>::remove(iterator& iter)
|
||||
{
|
||||
T* ptr = iter.object();
|
||||
this->parent_type::erase(iter);
|
||||
return ptr;
|
||||
if (iter.found())
|
||||
{
|
||||
T* ptr = iter.object();
|
||||
this->parent_type::erase(iter);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
bool Foam::HashPtrTable<T, Key, Hash>::erase(iterator& iter)
|
||||
{
|
||||
T* ptr = iter.object();
|
||||
|
||||
if (this->parent_type::erase(iter))
|
||||
if (iter.found())
|
||||
{
|
||||
if (ptr)
|
||||
T* ptr = iter.object();
|
||||
|
||||
if (this->parent_type::erase(iter))
|
||||
{
|
||||
delete ptr;
|
||||
}
|
||||
if (ptr)
|
||||
{
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
bool Foam::HashPtrTable<T, Key, Hash>::erase(const Key& key)
|
||||
{
|
||||
auto iter = this->find(key);
|
||||
return this->erase(iter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -116,12 +116,17 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Remove and return the pointer specified by given iterator
|
||||
//- Remove and return the pointer specified by given iterator.
|
||||
// Includes a safeguard against the end-iterator.
|
||||
T* remove(iterator& iter);
|
||||
|
||||
//- Erase an hashedEntry specified by given iterator
|
||||
//- Erase an entry specified by given iterator
|
||||
// Includes a safeguard against the end-iterator.
|
||||
bool erase(iterator& iter);
|
||||
|
||||
//- Erase an entry specified by the given key
|
||||
bool erase(const Key& key);
|
||||
|
||||
//- Clear all entries from table
|
||||
void clear();
|
||||
|
||||
|
||||
@ -227,16 +227,9 @@ void Foam::HashSet<Key, Hash>::operator|=(const HashSet<Key, Hash>& rhs)
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs)
|
||||
inline void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs)
|
||||
{
|
||||
// Remove elements not also found in rhs
|
||||
for (iterator iter = this->begin(); iter != this->end(); ++iter)
|
||||
{
|
||||
if (!rhs.found(iter.key()))
|
||||
{
|
||||
this->erase(iter);
|
||||
}
|
||||
}
|
||||
this->parent_type::retain(rhs);
|
||||
}
|
||||
|
||||
|
||||
@ -259,13 +252,9 @@ void Foam::HashSet<Key, Hash>::operator^=(const HashSet<Key, Hash>& rhs)
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
|
||||
inline void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
|
||||
{
|
||||
// Remove rhs elements from lhs
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
this->erase(iter.key());
|
||||
}
|
||||
this->parent_type::erase(rhs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -277,7 +277,7 @@ public:
|
||||
void operator|=(const HashSet<Key, Hash>& rhs);
|
||||
|
||||
//- Only retain entries found in both HashSets
|
||||
void operator&=(const HashSet<Key, Hash>& rhs);
|
||||
inline void operator&=(const HashSet<Key, Hash>& rhs);
|
||||
|
||||
//- Only retain unique entries (xor)
|
||||
void operator^=(const HashSet<Key, Hash>& rhs);
|
||||
@ -289,7 +289,7 @@ public:
|
||||
}
|
||||
|
||||
//- Remove entries listed in the given HashSet from this HashSet
|
||||
void operator-=(const HashSet<Key, Hash>& rhs);
|
||||
inline void operator-=(const HashSet<Key, Hash>& rhs);
|
||||
|
||||
|
||||
// IOstream Operator
|
||||
|
||||
@ -257,7 +257,7 @@ template<class T, class Key, class Hash>
|
||||
bool Foam::HashTable<T, Key, Hash>::set
|
||||
(
|
||||
const Key& key,
|
||||
const T& newEntry,
|
||||
const T& obj,
|
||||
const bool protect
|
||||
)
|
||||
{
|
||||
@ -284,7 +284,7 @@ bool Foam::HashTable<T, Key, Hash>::set
|
||||
if (!existing)
|
||||
{
|
||||
// Not found, insert it at the head
|
||||
table_[hashIdx] = new hashedEntry(key, newEntry, table_[hashIdx]);
|
||||
table_[hashIdx] = new hashedEntry(key, obj, table_[hashIdx]);
|
||||
nElmts_++;
|
||||
|
||||
if (double(nElmts_)/tableSize_ > 0.8 && tableSize_ < maxTableSize)
|
||||
@ -316,7 +316,7 @@ bool Foam::HashTable<T, Key, Hash>::set
|
||||
{
|
||||
// Found - overwrite existing entry
|
||||
// this corresponds to the Perl convention
|
||||
hashedEntry* ep = new hashedEntry(key, newEntry, existing->next_);
|
||||
hashedEntry* ep = new hashedEntry(key, obj, existing->next_);
|
||||
|
||||
// Replace existing element - within list or insert at the head
|
||||
if (prev)
|
||||
@ -411,7 +411,8 @@ bool Foam::HashTable<T, Key, Hash>::erase(const iterator& iter)
|
||||
template<class T, class Key, class Hash>
|
||||
bool Foam::HashTable<T, Key, Hash>::erase(const Key& key)
|
||||
{
|
||||
return erase(find(key));
|
||||
auto iter = find(key);
|
||||
return erase(iter);
|
||||
}
|
||||
|
||||
|
||||
@ -450,15 +451,15 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase
|
||||
const HashTable<AnyType, Key, AnyHash>& other
|
||||
)
|
||||
{
|
||||
// Remove other keys from this table
|
||||
const label nTotal = this->size();
|
||||
label changed = 0;
|
||||
|
||||
if (other.size() < nTotal)
|
||||
using other_iter =
|
||||
typename HashTable<AnyType, Key, AnyHash>::const_iterator;
|
||||
|
||||
if (other.size() <= nTotal)
|
||||
{
|
||||
// other is smaller, use its keys for removal
|
||||
using other_iter =
|
||||
typename HashTable<AnyType, Key, AnyHash>::const_iterator;
|
||||
// The other is smaller/same-size, use its keys for removal
|
||||
|
||||
for
|
||||
(
|
||||
@ -475,7 +476,7 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase
|
||||
}
|
||||
else
|
||||
{
|
||||
// other is same/larger: iterate ourselves and check for key in other
|
||||
// We are smaller: remove if found in the other hash
|
||||
for
|
||||
(
|
||||
iterator iter = begin();
|
||||
@ -494,6 +495,39 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class AnyType, class AnyHash>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::retain
|
||||
(
|
||||
const HashTable<AnyType, Key, AnyHash>& other
|
||||
)
|
||||
{
|
||||
const label nTotal = this->size();
|
||||
label changed = 0;
|
||||
|
||||
if (other.empty())
|
||||
{
|
||||
// Trivial case
|
||||
changed = nTotal;
|
||||
this->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Inverted logic: remove if *not* found in the other hash
|
||||
|
||||
for (iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
if (!other.found(iter.key()) && erase(iter))
|
||||
{
|
||||
++changed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
void Foam::HashTable<T, Key, Hash>::resize(const label sz)
|
||||
{
|
||||
|
||||
@ -44,6 +44,7 @@ Note
|
||||
SourceFiles
|
||||
HashTableI.H
|
||||
HashTable.C
|
||||
HashTableCoreI.H
|
||||
HashTableCore.C
|
||||
HashTableIO.C
|
||||
|
||||
@ -60,6 +61,7 @@ SourceFiles
|
||||
#include "nullObject.H"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -178,10 +180,17 @@ public:
|
||||
//- Type of values that the HashTable contains.
|
||||
typedef T value_type;
|
||||
|
||||
//- The type used for storing into value_type objects.
|
||||
// This type is usually value_type&.
|
||||
typedef T* pointer;
|
||||
|
||||
//- The type used for storing into value_type objects.
|
||||
// This type is usually value_type&.
|
||||
typedef T& reference;
|
||||
|
||||
//- The type used for reading from constant value_type objects.
|
||||
typedef const T* const_pointer;
|
||||
|
||||
//- The type used for reading from constant value_type objects.
|
||||
typedef const T& const_reference;
|
||||
|
||||
@ -247,7 +256,7 @@ private:
|
||||
|
||||
//- Assign a new hash-entry to a possibly already existing key.
|
||||
// Return true if the new entry was set.
|
||||
bool set(const Key& key, const T& newEntry, const bool protect);
|
||||
bool set(const Key& key, const T& obj, const bool protect);
|
||||
|
||||
|
||||
protected:
|
||||
@ -307,17 +316,20 @@ public:
|
||||
//- Return true if the hash table is empty
|
||||
inline bool empty() const;
|
||||
|
||||
//- Return true if hashedEntry is found in table
|
||||
//- Return true if hashed entry is found in table
|
||||
bool found(const Key& key) const;
|
||||
|
||||
//- Find and return an iterator set at the hashedEntry
|
||||
//- Find and return an iterator set at the hashed entry
|
||||
// If not found iterator = end()
|
||||
iterator find(const Key& key);
|
||||
|
||||
//- Find and return an const_iterator set at the hashedEntry
|
||||
//- Find and return an const_iterator set at the hashed entry
|
||||
// If not found iterator = end()
|
||||
const_iterator find(const Key& key) const;
|
||||
|
||||
//- Return hashed entry if it exists, or return the given default
|
||||
inline const T& lookup(const Key& key, const T& deflt) const;
|
||||
|
||||
//- Return the table of contents
|
||||
List<Key> toc() const;
|
||||
|
||||
@ -327,42 +339,58 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Insert a new hashedEntry
|
||||
//- Insert a new entry
|
||||
// Return true if the entry inserted, which means that it did
|
||||
// not previously exist in the table.
|
||||
inline bool insert(const Key& key, const T& newEntry);
|
||||
inline bool insert(const Key& key, const T& obj);
|
||||
|
||||
//- Assign a new hashedEntry, overwriting existing entries.
|
||||
//- Assign a new entry, overwriting existing entries.
|
||||
// Returns true.
|
||||
inline bool set(const Key& key, const T& newEntry);
|
||||
inline bool set(const Key& key, const T& obj);
|
||||
|
||||
//- Erase a hashedEntry specified by given iterator
|
||||
// This invalidates the iterator until the next ++ operation
|
||||
//- Erase an entry specified by given iterator
|
||||
// This invalidates the iterator until the next ++ operation.
|
||||
//
|
||||
// Includes a safeguard against the end-iterator such that the
|
||||
// following is safe:
|
||||
// \code
|
||||
// auto iter = table.find(unknownKey);
|
||||
// table.erase(iter);
|
||||
// \endcode
|
||||
// which is what \code table.erase(unknownKey) \endcode does anyhow
|
||||
bool erase(const iterator& iter);
|
||||
|
||||
//- Erase a hashedEntry specified by the given key
|
||||
//- Erase an entry specified by the given key
|
||||
bool erase(const Key& key);
|
||||
|
||||
//- Remove entries given by the listed keys from this HashTable
|
||||
//- Remove table entries given by the listed keys
|
||||
// Return the number of elements removed
|
||||
label erase(const UList<Key>& keys);
|
||||
|
||||
//- Remove entries given by the listed keys from this HashTable
|
||||
//- Remove table entries given by the listed keys
|
||||
// Return the number of elements removed
|
||||
template<unsigned Size>
|
||||
label erase(const FixedList<Key, Size>& keys);
|
||||
|
||||
//- Remove entries given by the listed keys from this HashTable
|
||||
//- Remove table entries given by the listed keys
|
||||
// Return the number of elements removed
|
||||
label erase(std::initializer_list<Key> keys);
|
||||
|
||||
//- Remove entries given by the given keys from this HashTable
|
||||
//- Remove table entries given by keys of the other hash-table.
|
||||
// Return the number of elements removed.
|
||||
// The parameter HashTable needs the same type of key, but the
|
||||
//
|
||||
// The other hash-table must have the same type of key, but the
|
||||
// type of values held and the hashing function are arbitrary.
|
||||
template<class AnyType, class AnyHash>
|
||||
label erase(const HashTable<AnyType, Key, AnyHash>& other);
|
||||
|
||||
//- Retain table entries given by keys of the other hash-table.
|
||||
//
|
||||
// The other hash-table must have the same type of key, but the
|
||||
// type of values held and the hashing function are arbitrary.
|
||||
template<class AnyType, class AnyHash>
|
||||
label retain(const HashTable<AnyType, Key, AnyHash>& other);
|
||||
|
||||
//- Resize the hash table for efficiency
|
||||
void resize(const label sz);
|
||||
|
||||
@ -383,10 +411,10 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Find and return a hashedEntry
|
||||
//- Find and return a hashed entry. FatalError if it does not exist.
|
||||
inline T& operator[](const Key& key);
|
||||
|
||||
//- Find and return a hashedEntry
|
||||
//- Find and return a hashed entry. FatalError if it does not exist.
|
||||
inline const T& operator[](const Key& key) const;
|
||||
|
||||
//- Return existing entry or create a new entry.
|
||||
@ -394,6 +422,12 @@ public:
|
||||
// value-initialized. For primitives, this will be zero.
|
||||
inline T& operator()(const Key& key);
|
||||
|
||||
//- Return existing entry or insert a new entry.
|
||||
inline T& operator()(const Key& key, const T& deflt);
|
||||
|
||||
//- Return hashed entry if it exists, or return the given default
|
||||
inline const T& operator()(const Key& key, const T& deflt) const;
|
||||
|
||||
//- Assignment
|
||||
void operator=(const HashTable<T, Key, Hash>& rhs);
|
||||
|
||||
@ -423,6 +457,7 @@ protected:
|
||||
// Public typedefs
|
||||
using table_type = this_type;
|
||||
using key_type = this_type::key_type;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using difference_type = this_type::difference_type;
|
||||
|
||||
private:
|
||||
@ -500,16 +535,20 @@ public:
|
||||
public WrappedIterator
|
||||
{
|
||||
public:
|
||||
using value_type = this_type::key_type;
|
||||
using pointer = const Key*;
|
||||
using reference = const Key&;
|
||||
using difference_type = typename WrappedIterator::difference_type;
|
||||
|
||||
//- Implicit conversion
|
||||
inline key_iterator_base(const WrappedIterator& iter);
|
||||
|
||||
//- Return the key
|
||||
inline reference operator*() const;
|
||||
};
|
||||
inline reference operator()() const;
|
||||
|
||||
inline key_iterator_base& operator++();
|
||||
inline key_iterator_base operator++(int);
|
||||
};
|
||||
|
||||
|
||||
// STL iterator
|
||||
@ -526,9 +565,9 @@ public:
|
||||
|
||||
// Public typedefs
|
||||
using table_type = this_type;
|
||||
using key_type = this_type::key_type;
|
||||
using value_type = this_type::value_type;
|
||||
using pointer = this_type::pointer;
|
||||
using reference = this_type::reference;
|
||||
using difference_type = typename iterator_base::difference_type;
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -574,9 +613,9 @@ public:
|
||||
|
||||
// Public typedefs
|
||||
using table_type = const this_type;
|
||||
using key_type = this_type::key_type;
|
||||
using value_type = const this_type::value_type;
|
||||
using pointer = this_type::const_pointer;
|
||||
using reference = this_type::const_reference;
|
||||
using difference_type = typename iterator_base::difference_type;
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
@ -79,10 +79,10 @@ template<class T, class Key, class Hash>
|
||||
inline bool Foam::HashTable<T, Key, Hash>::insert
|
||||
(
|
||||
const Key& key,
|
||||
const T& newEntry
|
||||
const T& obj
|
||||
)
|
||||
{
|
||||
return this->set(key, newEntry, true);
|
||||
return this->set(key, obj, true);
|
||||
}
|
||||
|
||||
|
||||
@ -90,10 +90,10 @@ template<class T, class Key, class Hash>
|
||||
inline bool Foam::HashTable<T, Key, Hash>::set
|
||||
(
|
||||
const Key& key,
|
||||
const T& newEntry
|
||||
const T& obj
|
||||
)
|
||||
{
|
||||
return this->set(key, newEntry, false);
|
||||
return this->set(key, obj, false);
|
||||
}
|
||||
|
||||
|
||||
@ -105,6 +105,18 @@ Foam::HashTable<T, Key, Hash>::xfer()
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline const T& Foam::HashTable<T, Key, Hash>::lookup
|
||||
(
|
||||
const Key& key,
|
||||
const T& deflt
|
||||
) const
|
||||
{
|
||||
const_iterator iter = this->find(key);
|
||||
return iter.found() ? iter.object() : deflt;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
@ -156,6 +168,36 @@ inline T& Foam::HashTable<T, Key, Hash>::operator()(const Key& key)
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline T& Foam::HashTable<T, Key, Hash>::operator()
|
||||
(
|
||||
const Key& key,
|
||||
const T& deflt
|
||||
)
|
||||
{
|
||||
iterator iter = this->find(key);
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
return iter.object();
|
||||
}
|
||||
|
||||
this->insert(key, deflt);
|
||||
return find(key).object();
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline const T& Foam::HashTable<T, Key, Hash>::operator()
|
||||
(
|
||||
const Key& key,
|
||||
const T& deflt
|
||||
) const
|
||||
{
|
||||
return this->lookup(key, deflt);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * iterator base * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
@ -321,6 +363,39 @@ Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class WrappedIterator>
|
||||
inline const Key&
|
||||
Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
|
||||
::operator()() const
|
||||
{
|
||||
return this->key();
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class WrappedIterator>
|
||||
inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>&
|
||||
Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
|
||||
::operator++()
|
||||
{
|
||||
this->increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class WrappedIterator>
|
||||
inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
|
||||
Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
|
||||
::operator++(int)
|
||||
{
|
||||
key_iterator_base old = *this;
|
||||
this->increment();
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
|
||||
@ -203,7 +203,7 @@ template<class T, class Key, class Hash>
|
||||
bool Foam::StaticHashTable<T, Key, Hash>::set
|
||||
(
|
||||
const Key& key,
|
||||
const T& newEntry,
|
||||
const T& obj,
|
||||
const bool protect
|
||||
)
|
||||
{
|
||||
@ -229,7 +229,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::set
|
||||
localObjects.setSize(existing+1);
|
||||
|
||||
localKeys[existing] = key;
|
||||
localObjects[existing] = newEntry;
|
||||
localObjects[existing] = obj;
|
||||
|
||||
nElmts_++;
|
||||
}
|
||||
@ -250,7 +250,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::set
|
||||
{
|
||||
// Found - overwrite existing entry
|
||||
// this corresponds to the Perl convention
|
||||
objects_[hashIdx][existing] = newEntry;
|
||||
objects_[hashIdx][existing] = obj;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -121,10 +121,10 @@ class StaticHashTable
|
||||
|
||||
//- Return the hash index of the Key within the current table size.
|
||||
// No checks for zero-sized tables.
|
||||
inline label hashKeyIndex(const Key&) const;
|
||||
inline label hashKeyIndex(const Key& key) const;
|
||||
|
||||
//- Assign a new hashed entry to a possibly already existing key
|
||||
bool set(const Key&, const T& newElmt, bool protect);
|
||||
bool set(const Key& key, const T& obj, bool protect);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -26,8 +26,6 @@ License
|
||||
#include "error.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Classes * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
@ -59,10 +57,10 @@ template<class T, class Key, class Hash>
|
||||
inline bool Foam::StaticHashTable<T, Key, Hash>::insert
|
||||
(
|
||||
const Key& key,
|
||||
const T& newEntry
|
||||
const T& obj
|
||||
)
|
||||
{
|
||||
return set(key, newEntry, true);
|
||||
return set(key, obj, true);
|
||||
}
|
||||
|
||||
|
||||
@ -70,10 +68,10 @@ template<class T, class Key, class Hash>
|
||||
inline bool Foam::StaticHashTable<T, Key, Hash>::set
|
||||
(
|
||||
const Key& key,
|
||||
const T& newEntry
|
||||
const T& obj
|
||||
)
|
||||
{
|
||||
return set(key, newEntry, false);
|
||||
return set(key, obj, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -254,14 +254,14 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
T& operator*()
|
||||
T& operator*() const
|
||||
{
|
||||
return
|
||||
static_cast<link&>
|
||||
(LListBase_iterator::operator*()).obj_;
|
||||
}
|
||||
|
||||
T& operator()()
|
||||
T& operator()() const
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
@ -312,14 +312,14 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
const T& operator*()
|
||||
const T& operator*() const
|
||||
{
|
||||
return
|
||||
static_cast<const link&>
|
||||
(LListBase_const_iterator::operator*()).obj_;
|
||||
}
|
||||
|
||||
const T& operator()()
|
||||
const T& operator()() const
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
|
||||
@ -196,12 +196,12 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
T& operator*()
|
||||
T& operator*() const
|
||||
{
|
||||
return *(LList<LListBase, T*>::iterator::operator*());
|
||||
}
|
||||
|
||||
T& operator()()
|
||||
T& operator()() const
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
@ -235,12 +235,12 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
const T& operator*()
|
||||
const T& operator*() const
|
||||
{
|
||||
return *(LList<LListBase, T*>::const_iterator::operator*());
|
||||
}
|
||||
|
||||
const T& operator()()
|
||||
const T& operator()() const
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
|
||||
@ -192,12 +192,12 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
T& operator*()
|
||||
T& operator*() const
|
||||
{
|
||||
return static_cast<T&>(LListBase_iterator::operator*());
|
||||
}
|
||||
|
||||
T& operator()()
|
||||
T& operator()() const
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
@ -247,14 +247,14 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
const T& operator*()
|
||||
const T& operator*() const
|
||||
{
|
||||
return
|
||||
static_cast<const T&>
|
||||
(LListBase_const_iterator::operator*());
|
||||
}
|
||||
|
||||
const T& operator()()
|
||||
const T& operator()() const
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
@ -309,14 +309,14 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
const T& operator*()
|
||||
const T& operator*() const
|
||||
{
|
||||
return
|
||||
static_cast<const T&>
|
||||
(LListBase::const_reverse_iterator::operator*());
|
||||
}
|
||||
|
||||
const T& operator()()
|
||||
const T& operator()() const
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ Foam::DLListBase::link* Foam::DLListBase::removeHead()
|
||||
|
||||
if (!first_)
|
||||
{
|
||||
last_ = 0;
|
||||
last_ = nullptr;
|
||||
}
|
||||
|
||||
f->deregister();
|
||||
@ -204,8 +204,8 @@ Foam::DLListBase::link* Foam::DLListBase::remove(DLListBase::link* l)
|
||||
|
||||
if (l == first_ && first_ == last_)
|
||||
{
|
||||
first_ = 0;
|
||||
last_ = 0;
|
||||
first_ = nullptr;
|
||||
last_ = nullptr;
|
||||
}
|
||||
else if (l == first_)
|
||||
{
|
||||
|
||||
@ -25,9 +25,10 @@ Class
|
||||
Foam::DLListBase
|
||||
|
||||
Description
|
||||
Base doubly-linked list.
|
||||
Base for doubly-linked lists.
|
||||
|
||||
SourceFiles
|
||||
DLListBaseI.H
|
||||
DLListBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -84,10 +85,10 @@ private:
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
DLListBase(const DLListBase&);
|
||||
DLListBase(const DLListBase&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const DLListBase&);
|
||||
void operator=(const DLListBase&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -184,18 +185,14 @@ public:
|
||||
friend class DLListBase;
|
||||
friend class const_iterator;
|
||||
|
||||
// Private data
|
||||
//- Reference to the list this is an iterator for
|
||||
DLListBase& curList_;
|
||||
|
||||
//- Reference to the list this is an iterator for
|
||||
DLListBase& curList_;
|
||||
//- Current element
|
||||
link* curElmt_;
|
||||
|
||||
//- Current element
|
||||
link* curElmt_;
|
||||
|
||||
//- Copy of the link
|
||||
link curLink_;
|
||||
|
||||
// Private Member Functions
|
||||
//- Copy of the link
|
||||
link curLink_;
|
||||
|
||||
//- Construct for a given SLListBase with nullptr element and link.
|
||||
// Only used to create endIter
|
||||
@ -206,17 +203,18 @@ public:
|
||||
//- Construct for a given DLListBase and link
|
||||
inline iterator(DLListBase&, link*);
|
||||
|
||||
// Member operators
|
||||
//- Currently pointing at a valid entry
|
||||
inline bool found() const;
|
||||
|
||||
inline void operator=(const iterator&);
|
||||
inline void operator=(const iterator& iter);
|
||||
|
||||
inline bool operator==(const iterator&) const;
|
||||
inline bool operator!=(const iterator&) const;
|
||||
inline bool operator==(const iterator& iter) const;
|
||||
inline bool operator!=(const iterator& iter) const;
|
||||
|
||||
inline link& operator*();
|
||||
inline link& operator*() const;
|
||||
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
};
|
||||
|
||||
inline iterator begin();
|
||||
@ -228,13 +226,11 @@ public:
|
||||
//- An STL-conforming const_iterator
|
||||
class const_iterator
|
||||
{
|
||||
// Private data
|
||||
//- Reference to the list this is an iterator for
|
||||
const DLListBase& curList_;
|
||||
|
||||
//- Reference to the list this is an iterator for
|
||||
const DLListBase& curList_;
|
||||
|
||||
//- Current element
|
||||
const link* curElmt_;
|
||||
//- Current element
|
||||
const link* curElmt_;
|
||||
|
||||
public:
|
||||
|
||||
@ -242,19 +238,20 @@ public:
|
||||
inline const_iterator(const DLListBase&, const link*);
|
||||
|
||||
//- Construct from a non-const iterator
|
||||
inline const_iterator(const iterator&);
|
||||
inline const_iterator(const DLListBase::iterator& iter);
|
||||
|
||||
// Member operators
|
||||
//- Currently pointing at a valid entry
|
||||
inline bool found() const;
|
||||
|
||||
inline void operator=(const const_iterator&);
|
||||
inline void operator=(const const_iterator& iter);
|
||||
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
|
||||
inline const link& operator*();
|
||||
inline const link& operator*() const;
|
||||
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
};
|
||||
|
||||
inline const_iterator cbegin() const;
|
||||
@ -269,30 +266,29 @@ public:
|
||||
//- An STL-conforming const_reverse_iterator
|
||||
class const_reverse_iterator
|
||||
{
|
||||
// Private data
|
||||
//- Reference to the list this is an reverse_iterator for
|
||||
const DLListBase& curList_;
|
||||
|
||||
//- Reference to the list this is an reverse_iterator for
|
||||
const DLListBase& curList_;
|
||||
|
||||
//- Current element
|
||||
const link* curElmt_;
|
||||
//- Current element
|
||||
const link* curElmt_;
|
||||
|
||||
public:
|
||||
|
||||
//- Construct for a given DLListBase and link
|
||||
inline const_reverse_iterator(const DLListBase&, const link*);
|
||||
inline const_reverse_iterator(const DLListBase& lst, const link*);
|
||||
|
||||
// Member operators
|
||||
//- Currently pointing at a valid entry
|
||||
inline bool found() const;
|
||||
|
||||
inline void operator=(const const_reverse_iterator&);
|
||||
inline void operator=(const const_reverse_iterator& iter);
|
||||
|
||||
inline bool operator==(const const_reverse_iterator&) const;
|
||||
inline bool operator!=(const const_reverse_iterator&) const;
|
||||
inline bool operator==(const const_reverse_iterator& iter) const;
|
||||
inline bool operator!=(const const_reverse_iterator& iter) const;
|
||||
|
||||
inline const link& operator*();
|
||||
inline const link& operator*() const;
|
||||
|
||||
inline const_reverse_iterator& operator++();
|
||||
inline const_reverse_iterator operator++(int);
|
||||
inline const_reverse_iterator& operator++();
|
||||
inline const_reverse_iterator operator++(int);
|
||||
};
|
||||
|
||||
inline const_reverse_iterator crbegin() const;
|
||||
|
||||
@ -29,15 +29,15 @@ License
|
||||
|
||||
inline Foam::DLListBase::link::link()
|
||||
:
|
||||
prev_(0),
|
||||
next_(0)
|
||||
prev_(nullptr),
|
||||
next_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::DLListBase::DLListBase()
|
||||
:
|
||||
first_(0),
|
||||
last_(0),
|
||||
first_(nullptr),
|
||||
last_(nullptr),
|
||||
nElmts_(0)
|
||||
{}
|
||||
|
||||
@ -63,14 +63,14 @@ inline Foam::DLListBase::~DLListBase()
|
||||
|
||||
inline bool Foam::DLListBase::link::registered() const
|
||||
{
|
||||
return prev_ != 0 && next_ != 0;
|
||||
return prev_ != nullptr && next_ != nullptr;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::DLListBase::link::deregister()
|
||||
{
|
||||
prev_ = 0;
|
||||
next_ = 0;
|
||||
prev_ = nullptr;
|
||||
next_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -140,8 +140,8 @@ Foam::DLListBase::last() const
|
||||
|
||||
inline void Foam::DLListBase::clear()
|
||||
{
|
||||
first_ = 0;
|
||||
last_ = 0;
|
||||
first_ = nullptr;
|
||||
last_ = nullptr;
|
||||
nElmts_ = 0;
|
||||
}
|
||||
|
||||
@ -195,6 +195,12 @@ inline Foam::DLListBase::iterator::iterator(DLListBase& s)
|
||||
{}
|
||||
|
||||
|
||||
inline bool Foam::DLListBase::iterator::found() const
|
||||
{
|
||||
return (curElmt_ != nullptr);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::DLListBase::iterator::operator=(const iterator& iter)
|
||||
{
|
||||
curElmt_ = iter.curElmt_;
|
||||
@ -215,7 +221,7 @@ inline bool Foam::DLListBase::iterator::operator!=(const iterator& iter) const
|
||||
|
||||
|
||||
inline Foam::DLListBase::link&
|
||||
Foam::DLListBase::iterator::operator*()
|
||||
Foam::DLListBase::iterator::operator*() const
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
@ -226,9 +232,9 @@ Foam::DLListBase::iterator::operator++()
|
||||
{
|
||||
// Check if the curElmt_ is the last element (if it points to itself)
|
||||
// or if the list is empty because the last element may have been removed
|
||||
if (curLink_.next_ == curElmt_ || curList_.last_ == 0)
|
||||
if (curLink_.next_ == curElmt_ || curList_.last_ == nullptr)
|
||||
{
|
||||
curElmt_ = 0;
|
||||
curElmt_ = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -282,13 +288,22 @@ inline Foam::DLListBase::const_iterator::const_iterator
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::DLListBase::const_iterator::const_iterator(const iterator& iter)
|
||||
inline Foam::DLListBase::const_iterator::const_iterator
|
||||
(
|
||||
const DLListBase::iterator& iter
|
||||
)
|
||||
:
|
||||
curList_(iter.curList_),
|
||||
curElmt_(iter.curElmt_)
|
||||
{}
|
||||
|
||||
|
||||
inline bool Foam::DLListBase::const_iterator::found() const
|
||||
{
|
||||
return (curElmt_ != nullptr);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::DLListBase::const_iterator::operator=
|
||||
(
|
||||
const const_iterator& iter
|
||||
@ -317,7 +332,7 @@ inline bool Foam::DLListBase::const_iterator::operator!=
|
||||
|
||||
|
||||
inline const Foam::DLListBase::link&
|
||||
Foam::DLListBase::const_iterator::operator*()
|
||||
Foam::DLListBase::const_iterator::operator*() const
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
@ -328,7 +343,7 @@ Foam::DLListBase::const_iterator::operator++()
|
||||
{
|
||||
if (curElmt_ == curList_.last_)
|
||||
{
|
||||
curElmt_ = 0;
|
||||
curElmt_ = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -387,15 +402,21 @@ Foam::DLListBase::end() const
|
||||
|
||||
inline Foam::DLListBase::const_reverse_iterator::const_reverse_iterator
|
||||
(
|
||||
const DLListBase& s,
|
||||
const DLListBase& lst,
|
||||
const link* elmt
|
||||
)
|
||||
:
|
||||
curList_(s),
|
||||
curList_(lst),
|
||||
curElmt_(elmt)
|
||||
{}
|
||||
|
||||
|
||||
inline bool Foam::DLListBase::const_reverse_iterator::found() const
|
||||
{
|
||||
return (curElmt_ != nullptr);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::DLListBase::const_reverse_iterator::operator=
|
||||
(
|
||||
const const_reverse_iterator& iter
|
||||
@ -424,7 +445,7 @@ inline bool Foam::DLListBase::const_reverse_iterator::operator!=
|
||||
|
||||
|
||||
inline const Foam::DLListBase::link&
|
||||
Foam::DLListBase::const_reverse_iterator::operator*()
|
||||
Foam::DLListBase::const_reverse_iterator::operator*() const
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
@ -435,7 +456,7 @@ Foam::DLListBase::const_reverse_iterator::operator++()
|
||||
{
|
||||
if (curElmt_ == curList_.first_)
|
||||
{
|
||||
curElmt_ = 0;
|
||||
curElmt_ = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -460,7 +481,7 @@ Foam::DLListBase::crbegin() const
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
return const_reverse_iterator(*this, last());
|
||||
return const_reverse_iterator(*this, this->last());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -79,7 +79,7 @@ Foam::SLListBase::link* Foam::SLListBase::removeHead()
|
||||
{
|
||||
nElmts_--;
|
||||
|
||||
if (last_ == 0)
|
||||
if (last_ == nullptr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "remove from empty list"
|
||||
@ -90,7 +90,7 @@ Foam::SLListBase::link* Foam::SLListBase::removeHead()
|
||||
|
||||
if (f == last_)
|
||||
{
|
||||
last_ = 0;
|
||||
last_ = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -132,7 +132,7 @@ Foam::SLListBase::link* Foam::SLListBase::remove(SLListBase::link* it)
|
||||
prev = p;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,9 +25,10 @@ Class
|
||||
Foam::SLListBase
|
||||
|
||||
Description
|
||||
Base singly-linked list.
|
||||
Base for singly-linked lists.
|
||||
|
||||
SourceFiles
|
||||
SLListBaseI.H
|
||||
SLListBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -81,10 +82,10 @@ private:
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
SLListBase(const SLListBase&);
|
||||
SLListBase(const SLListBase&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const SLListBase&);
|
||||
void operator=(const SLListBase&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -166,18 +167,14 @@ public:
|
||||
friend class SLListBase;
|
||||
friend class const_iterator;
|
||||
|
||||
// Private data
|
||||
//- Reference to the list this is an iterator for
|
||||
SLListBase& curList_;
|
||||
|
||||
//- Reference to the list this is an iterator for
|
||||
SLListBase& curList_;
|
||||
//- Current element
|
||||
link* curElmt_;
|
||||
|
||||
//- Current element
|
||||
link* curElmt_;
|
||||
|
||||
//- Copy of the link
|
||||
link curLink_;
|
||||
|
||||
// Private Member Functions
|
||||
//- Copy of the link
|
||||
link curLink_;
|
||||
|
||||
//- Construct for a given SLListBase with nullptr element and link.
|
||||
// Only used to create endIter
|
||||
@ -188,17 +185,18 @@ public:
|
||||
//- Construct for a given SLListBase and link
|
||||
inline iterator(SLListBase&, link*);
|
||||
|
||||
// Member operators
|
||||
//- Currently pointing at a valid entry
|
||||
inline bool found() const;
|
||||
|
||||
inline void operator=(const iterator&);
|
||||
inline void operator=(const iterator& iter);
|
||||
|
||||
inline bool operator==(const iterator&) const;
|
||||
inline bool operator!=(const iterator&) const;
|
||||
inline bool operator==(const iterator& iter) const;
|
||||
inline bool operator!=(const iterator& iter) const;
|
||||
|
||||
inline link& operator*();
|
||||
inline link& operator*() const;
|
||||
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
};
|
||||
|
||||
inline iterator begin();
|
||||
@ -210,13 +208,11 @@ public:
|
||||
//- An STL-conforming const_iterator
|
||||
class const_iterator
|
||||
{
|
||||
// Private data
|
||||
//- Reference to the list this is an iterator for
|
||||
const SLListBase& curList_;
|
||||
|
||||
//- Reference to the list this is an iterator for
|
||||
const SLListBase& curList_;
|
||||
|
||||
//- Current element
|
||||
const link* curElmt_;
|
||||
//- Current element
|
||||
const link* curElmt_;
|
||||
|
||||
public:
|
||||
|
||||
@ -224,20 +220,20 @@ public:
|
||||
inline const_iterator(const SLListBase&, const link*);
|
||||
|
||||
//- Construct from a non-const iterator
|
||||
inline const_iterator(const iterator&);
|
||||
inline const_iterator(const SLListBase::iterator& iter);
|
||||
|
||||
//- Currently pointing at a valid entry
|
||||
inline bool found() const;
|
||||
|
||||
// Member operators
|
||||
inline void operator=(const const_iterator& iter);
|
||||
|
||||
inline void operator=(const const_iterator&);
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
inline const link& operator*() const;
|
||||
|
||||
inline const link& operator*();
|
||||
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
};
|
||||
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
@ -21,9 +21,6 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Base singly-linked list.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
@ -32,7 +29,7 @@ Description
|
||||
|
||||
inline Foam::SLListBase::link::link()
|
||||
:
|
||||
next_(0)
|
||||
next_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -44,16 +41,22 @@ inline Foam::SLListBase::link::link(link* p)
|
||||
|
||||
inline Foam::SLListBase::SLListBase()
|
||||
:
|
||||
last_(0),
|
||||
last_(nullptr),
|
||||
nElmts_(0)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::SLListBase::SLListBase(link* a)
|
||||
:
|
||||
last_(a->next_ = a),
|
||||
nElmts_(1)
|
||||
{}
|
||||
last_(a),
|
||||
nElmts_(0)
|
||||
{
|
||||
if (a) // protect against nullptr
|
||||
{
|
||||
a->next_ = a;
|
||||
nElmts_ = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
@ -130,7 +133,7 @@ Foam::SLListBase::last() const
|
||||
|
||||
inline void Foam::SLListBase::clear()
|
||||
{
|
||||
last_ = 0;
|
||||
last_ = nullptr;
|
||||
nElmts_ = 0;
|
||||
}
|
||||
|
||||
@ -171,6 +174,12 @@ inline Foam::SLListBase::iterator::iterator(SLListBase& s)
|
||||
{}
|
||||
|
||||
|
||||
inline bool Foam::SLListBase::iterator::found() const
|
||||
{
|
||||
return (curElmt_ != nullptr);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::SLListBase::iterator::operator=(const iterator& iter)
|
||||
{
|
||||
curElmt_ = iter.curElmt_;
|
||||
@ -190,7 +199,7 @@ inline bool Foam::SLListBase::iterator::operator!=(const iterator& iter) const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::SLListBase::link& Foam::SLListBase::iterator::operator*()
|
||||
inline Foam::SLListBase::link& Foam::SLListBase::iterator::operator*() const
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
@ -198,9 +207,9 @@ inline Foam::SLListBase::link& Foam::SLListBase::iterator::operator*()
|
||||
|
||||
inline Foam::SLListBase::iterator& Foam::SLListBase::iterator::operator++()
|
||||
{
|
||||
if (curElmt_ == curList_.last_ || curList_.last_ == 0)
|
||||
if (curElmt_ == curList_.last_ || curList_.last_ == nullptr)
|
||||
{
|
||||
curElmt_ = 0;
|
||||
curElmt_ = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -255,13 +264,22 @@ inline Foam::SLListBase::const_iterator::const_iterator
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::SLListBase::const_iterator::const_iterator(const iterator& iter)
|
||||
inline Foam::SLListBase::const_iterator::const_iterator
|
||||
(
|
||||
const SLListBase::iterator& iter
|
||||
)
|
||||
:
|
||||
curList_(iter.curList_),
|
||||
curElmt_(iter.curElmt_)
|
||||
{}
|
||||
|
||||
|
||||
inline bool Foam::SLListBase::const_iterator::found() const
|
||||
{
|
||||
return (curElmt_ != nullptr);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::SLListBase::const_iterator::operator=
|
||||
(
|
||||
const const_iterator& iter
|
||||
@ -290,7 +308,7 @@ inline bool Foam::SLListBase::const_iterator::operator!=
|
||||
|
||||
|
||||
inline const Foam::SLListBase::link&
|
||||
Foam::SLListBase::const_iterator::operator*()
|
||||
Foam::SLListBase::const_iterator::operator*() const
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
@ -301,7 +319,7 @@ Foam::SLListBase::const_iterator::operator++()
|
||||
{
|
||||
if (curElmt_ == curList_.last_)
|
||||
{
|
||||
curElmt_ = 0;
|
||||
curElmt_ = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,14 +59,14 @@ class DynamicList;
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
);
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
Istream& operator>>
|
||||
(
|
||||
Istream&,
|
||||
DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
Istream& is,
|
||||
DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
);
|
||||
|
||||
|
||||
@ -105,29 +105,37 @@ public:
|
||||
inline DynamicList();
|
||||
|
||||
//- Construct given size.
|
||||
explicit inline DynamicList(const label);
|
||||
explicit inline DynamicList(const label nElem);
|
||||
|
||||
//- Construct with given size and value for all elements.
|
||||
inline DynamicList(const label, const T&);
|
||||
inline DynamicList(const label nElem, const T& a);
|
||||
|
||||
//- Construct copy.
|
||||
inline DynamicList(const DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
||||
inline DynamicList
|
||||
(
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
);
|
||||
|
||||
//- Construct from UList. Size set to UList size.
|
||||
// Also constructs from DynamicList with different sizing parameters.
|
||||
explicit inline DynamicList(const UList<T>&);
|
||||
explicit inline DynamicList(const UList<T>& lst);
|
||||
|
||||
//- Construct given begin/end iterators.
|
||||
// Uses std::distance to determine the size.
|
||||
template<class InputIterator>
|
||||
inline DynamicList(InputIterator begIter, InputIterator endIter);
|
||||
|
||||
//- Construct from an initializer list. Size set to list size.
|
||||
explicit inline DynamicList(std::initializer_list<T>);
|
||||
explicit inline DynamicList(std::initializer_list<T> lst);
|
||||
|
||||
//- Construct from UIndirectList. Size set to UIndirectList size.
|
||||
explicit inline DynamicList(const UIndirectList<T>&);
|
||||
explicit inline DynamicList(const UIndirectList<T>& lst);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
explicit inline DynamicList(const Xfer<List<T>>&);
|
||||
explicit inline DynamicList(const Xfer<List<T>>& lst);
|
||||
|
||||
//- Construct from Istream. Size set to size of list read.
|
||||
explicit DynamicList(Istream&);
|
||||
explicit DynamicList(Istream& is);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -143,31 +151,31 @@ public:
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
// Use this or reserve() in combination with append().
|
||||
inline void setCapacity(const label);
|
||||
inline void setCapacity(const label nElem);
|
||||
|
||||
//- Alter the addressed list size.
|
||||
// New space will be allocated if required.
|
||||
// Use this to resize the list prior to using the operator[] for
|
||||
// setting values (as per List usage).
|
||||
inline void setSize(const label);
|
||||
inline void setSize(const label nElem);
|
||||
|
||||
//- Alter the addressed list size and fill new space with a
|
||||
// constant.
|
||||
inline void setSize(const label, const T&);
|
||||
inline void setSize(const label nElem, const T& t);
|
||||
|
||||
//- Alter the addressed list size.
|
||||
// New space will be allocated if required.
|
||||
// Use this to resize the list prior to using the operator[] for
|
||||
// setting values (as per List usage).
|
||||
inline void resize(const label);
|
||||
inline void resize(const label nElem);
|
||||
|
||||
//- Alter the addressed list size and fill new space with a
|
||||
// constant.
|
||||
inline void resize(const label, const T&);
|
||||
inline void resize(const label nElem, const T& t);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size, use setCapacity() for that.
|
||||
inline void reserve(const label);
|
||||
inline void reserve(const label nElem);
|
||||
|
||||
//- Clear the addressed list, i.e. set the size to zero.
|
||||
// Allocated size does not change
|
||||
@ -181,10 +189,13 @@ public:
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& shrink();
|
||||
|
||||
//- Transfer contents of the argument List into this.
|
||||
inline void transfer(List<T>&);
|
||||
inline void transfer(List<T>& lst);
|
||||
|
||||
//- Transfer contents of the argument DynamicList into this.
|
||||
inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
||||
inline void transfer
|
||||
(
|
||||
DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
);
|
||||
|
||||
//- Transfer contents to the Xfer container as a plain List
|
||||
inline Xfer<List<T>> xfer();
|
||||
@ -195,25 +206,25 @@ public:
|
||||
//- Append an element at the end of the list
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||
(
|
||||
const T&
|
||||
const T& t
|
||||
);
|
||||
|
||||
//- Append a List at the end of this list
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||
(
|
||||
const UList<T>&
|
||||
const UList<T>& lst
|
||||
);
|
||||
|
||||
//- Append an initializer list at the end of this list.
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||
(
|
||||
std::initializer_list<T>
|
||||
std::initializer_list<T> lst
|
||||
);
|
||||
|
||||
//- Append a UIndirectList at the end of this list
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||
(
|
||||
const UIndirectList<T>&
|
||||
const UIndirectList<T>& lst
|
||||
);
|
||||
|
||||
//- Remove and return the top element
|
||||
@ -221,32 +232,35 @@ public:
|
||||
|
||||
//- Return non-const access to an element, resizing list if
|
||||
// necessary
|
||||
inline T& operator()(const label);
|
||||
inline T& operator()(const label elemI);
|
||||
|
||||
//- Assignment of all addressed entries to the given value
|
||||
inline void operator=(const T&);
|
||||
inline void operator=(const T& t);
|
||||
|
||||
//- Assignment to DynamicList
|
||||
inline void operator=
|
||||
(
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
);
|
||||
|
||||
//- Assignment to UList
|
||||
inline void operator=(const UList<T>&);
|
||||
inline void operator=(const UList<T>& lst);
|
||||
|
||||
//- Assignment from initializer list
|
||||
inline void operator=(std::initializer_list<T>);
|
||||
inline void operator=(std::initializer_list<T> lst);
|
||||
|
||||
//- Assignment to UIndirectList
|
||||
inline void operator=(const UIndirectList<T>&);
|
||||
inline void operator=(const UIndirectList<T>& lst);
|
||||
|
||||
|
||||
// STL member functions
|
||||
|
||||
//- Erase an element, move the remaining elements to fill the gap
|
||||
// and resize the List
|
||||
typename UList<T>::iterator erase(typename UList<T>::iterator);
|
||||
typename UList<T>::iterator erase
|
||||
(
|
||||
typename UList<T>::iterator curIter
|
||||
);
|
||||
|
||||
|
||||
// IOstream operators
|
||||
@ -254,15 +268,15 @@ public:
|
||||
// Write DynamicList to Ostream.
|
||||
friend Ostream& operator<< <T, SizeInc, SizeMult, SizeDiv>
|
||||
(
|
||||
Ostream&,
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
);
|
||||
|
||||
//- Read from Istream, discarding contents of existing DynamicList.
|
||||
friend Istream& operator>> <T, SizeInc, SizeMult, SizeDiv>
|
||||
(
|
||||
Istream&,
|
||||
DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
Istream& is,
|
||||
DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -80,6 +80,19 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||
{}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
template<class InputIterator>
|
||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||
(
|
||||
InputIterator begIter,
|
||||
InputIterator endIter
|
||||
)
|
||||
:
|
||||
List<T>(begIter, endIter),
|
||||
capacity_(this->size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||
(
|
||||
|
||||
@ -128,11 +128,12 @@ public:
|
||||
explicit inline FixedList(const T& t);
|
||||
|
||||
//- Construct from C-array
|
||||
explicit inline FixedList(const T v[Size]);
|
||||
explicit inline FixedList(const T lst[Size]);
|
||||
|
||||
//- Construct given start and end iterators
|
||||
//- Construct given begin/end iterators
|
||||
// Uses std::distance when verifying the size.
|
||||
template<class InputIterator>
|
||||
inline FixedList(InputIterator first, InputIterator last);
|
||||
inline FixedList(InputIterator begIter, InputIterator endIter);
|
||||
|
||||
//- Construct from an initializer list
|
||||
inline FixedList(std::initializer_list<T> lst);
|
||||
|
||||
@ -37,7 +37,7 @@ inline Foam::FixedList<T, Size>::FixedList()
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const T& t)
|
||||
{
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = t;
|
||||
}
|
||||
@ -45,11 +45,11 @@ inline Foam::FixedList<T, Size>::FixedList(const T& t)
|
||||
|
||||
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const T v[Size])
|
||||
inline Foam::FixedList<T, Size>::FixedList(const T lst[Size])
|
||||
{
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = v[i];
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,25 +58,33 @@ template<class T, unsigned Size>
|
||||
template<class InputIterator>
|
||||
Foam::FixedList<T, Size>::FixedList
|
||||
(
|
||||
InputIterator first,
|
||||
InputIterator last
|
||||
InputIterator begIter,
|
||||
InputIterator endIter
|
||||
)
|
||||
{
|
||||
checkSize(std::distance(first, last));
|
||||
checkSize(std::distance(begIter, endIter));
|
||||
|
||||
InputIterator iter = first;
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
InputIterator iter = begIter;
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = *iter++;
|
||||
v_[i] = *iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(std::initializer_list<T> lst)
|
||||
:
|
||||
FixedList<T, Size>(lst.begin(), lst.end())
|
||||
{}
|
||||
{
|
||||
checkSize(lst.size());
|
||||
|
||||
auto iter = lst.begin();
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = *iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned Size>
|
||||
@ -84,7 +92,7 @@ inline Foam::FixedList<T, Size>::FixedList(const UList<T>& lst)
|
||||
{
|
||||
checkSize(lst.size());
|
||||
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
@ -97,9 +105,10 @@ inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& lst)
|
||||
checkSize(lst.size());
|
||||
|
||||
typename SLList<T>::const_iterator iter = lst.begin();
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = *iter++;
|
||||
v_[i] = *iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +116,7 @@ inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& lst)
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& lst)
|
||||
{
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
@ -200,7 +209,7 @@ inline void Foam::FixedList<T, Size>::setSize(const label s)
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::transfer(const FixedList<T, Size>& lst)
|
||||
{
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
@ -276,7 +285,7 @@ inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::operator=(const T lst[Size])
|
||||
{
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
@ -287,7 +296,7 @@ inline void Foam::FixedList<T, Size>::operator=(const UList<T>& lst)
|
||||
{
|
||||
checkSize(lst.size());
|
||||
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
@ -299,9 +308,10 @@ inline void Foam::FixedList<T, Size>::operator=(const SLList<T>& lst)
|
||||
checkSize(lst.size());
|
||||
|
||||
typename SLList<T>::const_iterator iter = lst.begin();
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = *iter++;
|
||||
v_[i] = *iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,17 +320,18 @@ inline void Foam::FixedList<T, Size>::operator=(std::initializer_list<T> lst)
|
||||
{
|
||||
checkSize(lst.size());
|
||||
|
||||
typename std::initializer_list<T>::iterator iter = lst.begin();
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
auto iter = lst.begin();
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = *iter++;
|
||||
v_[i] = *iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::operator=(const T& t)
|
||||
{
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
v_[i] = t;
|
||||
}
|
||||
@ -464,7 +475,7 @@ inline unsigned Foam::FixedList<T, Size>::Hash<HashT>::operator()
|
||||
// Hash incrementally
|
||||
unsigned val = seed;
|
||||
|
||||
for (unsigned i=0; i<Size; i++)
|
||||
for (unsigned i=0; i<Size; ++i)
|
||||
{
|
||||
val = HashT()(lst[i], val);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -160,7 +160,7 @@ Foam::List<T>::List(List<T>& a, bool reuse)
|
||||
if (reuse)
|
||||
{
|
||||
this->v_ = a.v_;
|
||||
a.v_ = 0;
|
||||
a.v_ = nullptr;
|
||||
a.size_ = 0;
|
||||
}
|
||||
else if (this->size_)
|
||||
@ -186,19 +186,19 @@ Foam::List<T>::List(List<T>& a, bool reuse)
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UList<T>& a, const labelUList& map)
|
||||
Foam::List<T>::List(const UList<T>& a, const labelUList& mapAddressing)
|
||||
:
|
||||
UList<T>(nullptr, map.size())
|
||||
UList<T>(nullptr, mapAddressing.size())
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
// Note:cannot use List_ELEM since third argument has to be index.
|
||||
// Note: cannot use List_ELEM since third argument has to be index.
|
||||
|
||||
alloc();
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
this->operator[](i) = a[map[i]];
|
||||
this->operator[](i) = a[mapAddressing[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,9 +206,9 @@ Foam::List<T>::List(const UList<T>& a, const labelUList& map)
|
||||
|
||||
template<class T>
|
||||
template<class InputIterator>
|
||||
Foam::List<T>::List(InputIterator first, InputIterator last)
|
||||
Foam::List<T>::List(InputIterator begIter, InputIterator endIter)
|
||||
:
|
||||
List<T>(first, last, std::distance(first, last))
|
||||
List<T>(begIter, endIter, std::distance(begIter, endIter))
|
||||
{}
|
||||
|
||||
|
||||
@ -231,6 +231,8 @@ Foam::List<T>::List(const PtrList<T>& lst)
|
||||
}
|
||||
|
||||
|
||||
// Note: using first/last is not entirely accurate.
|
||||
// But since the list size is correct, last() is actually ignored.
|
||||
template<class T>
|
||||
Foam::List<T>::List(const SLList<T>& lst)
|
||||
:
|
||||
@ -259,7 +261,7 @@ Foam::List<T>::List(const BiIndirectList<T>& lst)
|
||||
template<class T>
|
||||
Foam::List<T>::List(std::initializer_list<T> lst)
|
||||
:
|
||||
List<T>(lst.begin(), lst.end())
|
||||
List<T>(lst.begin(), lst.end(), lst.size())
|
||||
{}
|
||||
|
||||
|
||||
@ -326,7 +328,7 @@ void Foam::List<T>::setSize(const label newSize)
|
||||
template<class T>
|
||||
void Foam::List<T>::setSize(const label newSize, const T& a)
|
||||
{
|
||||
label oldSize = label(this->size_);
|
||||
const label oldSize = label(this->size_);
|
||||
this->setSize(newSize);
|
||||
|
||||
if (newSize > oldSize)
|
||||
@ -346,7 +348,7 @@ void Foam::List<T>::transfer(List<T>& a)
|
||||
this->v_ = a.v_;
|
||||
|
||||
a.size_ = 0;
|
||||
a.v_ = 0;
|
||||
a.v_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -419,14 +421,9 @@ void Foam::List<T>::operator=(const SLList<T>& lst)
|
||||
if (this->size_)
|
||||
{
|
||||
label i = 0;
|
||||
for
|
||||
(
|
||||
typename SLList<T>::const_iterator iter = lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
|
||||
{
|
||||
this->operator[](i++) = iter();
|
||||
this->operator[](i++) = *iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -453,10 +450,11 @@ void Foam::List<T>::operator=(std::initializer_list<T> lst)
|
||||
{
|
||||
reAlloc(lst.size());
|
||||
|
||||
typename std::initializer_list<T>::iterator iter = lst.begin();
|
||||
auto iter = lst.begin();
|
||||
forAll(*this, i)
|
||||
{
|
||||
this->operator[](i) = *iter++;
|
||||
this->operator[](i) = *iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ class Ostream;
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class T> class List;
|
||||
|
||||
template<class T> Istream& operator>>(Istream&, List<T>&);
|
||||
template<class T> Istream& operator>>(Istream& is, List<T>& L);
|
||||
|
||||
template<class T, unsigned Size> class FixedList;
|
||||
template<class T> class PtrList;
|
||||
@ -95,22 +95,28 @@ class List
|
||||
|
||||
//- Copy list of given type
|
||||
template<class List2>
|
||||
inline void copyList(const List2&);
|
||||
inline void copyList(const List2& lst);
|
||||
|
||||
//- Allocate storage and copy list of given type
|
||||
template<class List2>
|
||||
inline void allocCopyList(const List2&);
|
||||
inline void allocCopyList(const List2& lst);
|
||||
|
||||
//- Construct given start and end iterators and number of elements
|
||||
//- Construct given begin/end iterators and number of elements
|
||||
// Since the size is provided, the end iterator is actually ignored.
|
||||
template<class InputIterator>
|
||||
inline List(InputIterator first, InputIterator last, const label s);
|
||||
inline List
|
||||
(
|
||||
InputIterator begIter,
|
||||
InputIterator endIter,
|
||||
const label s
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//- Override size to be inconsistent with allocated storage.
|
||||
// Use with care
|
||||
inline void size(const label);
|
||||
inline void size(const label n);
|
||||
|
||||
|
||||
public:
|
||||
@ -127,55 +133,56 @@ public:
|
||||
inline List();
|
||||
|
||||
//- Construct with given size
|
||||
explicit List(const label);
|
||||
explicit List(const label s);
|
||||
|
||||
//- Construct with given size and value for all elements
|
||||
List(const label, const T&);
|
||||
List(const label s, const T& a);
|
||||
|
||||
//- Construct with given size initializing all elements to zero
|
||||
List(const label, const zero);
|
||||
List(const label s, const zero);
|
||||
|
||||
//- Copy constructor
|
||||
List(const List<T>&);
|
||||
List(const List<T>& a);
|
||||
|
||||
//- Copy constructor from list containing another type
|
||||
template<class T2>
|
||||
explicit List(const List<T2>&);
|
||||
explicit List(const List<T2>& a);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
List(const Xfer<List<T>>&);
|
||||
List(const Xfer<List<T>>& lst);
|
||||
|
||||
//- Construct as copy or re-use as specified
|
||||
List(List<T>&, bool reuse);
|
||||
List(List<T>& a, bool reuse);
|
||||
|
||||
//- Construct as subset
|
||||
List(const UList<T>&, const labelUList& mapAddressing);
|
||||
List(const UList<T>& a, const labelUList& mapAddressing);
|
||||
|
||||
//- Construct given start and end iterators
|
||||
//- Construct given begin/end iterators.
|
||||
// Uses std::distance to determine the size.
|
||||
template<class InputIterator>
|
||||
List(InputIterator first, InputIterator last);
|
||||
List(InputIterator begIter, InputIterator endIter);
|
||||
|
||||
//- Construct as copy of FixedList<T, Size>
|
||||
template<unsigned Size>
|
||||
explicit List(const FixedList<T, Size>&);
|
||||
explicit List(const FixedList<T, Size>& lst);
|
||||
|
||||
//- Construct as copy of PtrList<T>
|
||||
explicit List(const PtrList<T>&);
|
||||
explicit List(const PtrList<T>& lst);
|
||||
|
||||
//- Construct as copy of SLList<T>
|
||||
explicit List(const SLList<T>&);
|
||||
explicit List(const SLList<T>& lst);
|
||||
|
||||
//- Construct as copy of UIndirectList<T>
|
||||
explicit List(const UIndirectList<T>&);
|
||||
explicit List(const UIndirectList<T>& lst);
|
||||
|
||||
//- Construct as copy of BiIndirectList<T>
|
||||
explicit List(const BiIndirectList<T>&);
|
||||
explicit List(const BiIndirectList<T>& lst);
|
||||
|
||||
//- Construct from an initializer list
|
||||
List(std::initializer_list<T>);
|
||||
List(std::initializer_list<T> lst);
|
||||
|
||||
//- Construct from Istream
|
||||
List(Istream&);
|
||||
List(Istream& is);
|
||||
|
||||
//- Clone
|
||||
inline autoPtr<List<T>> clone() const;
|
||||
@ -200,47 +207,48 @@ public:
|
||||
// Edit
|
||||
|
||||
//- Alias for setSize(const label)
|
||||
inline void resize(const label);
|
||||
inline void resize(const label newSize);
|
||||
|
||||
//- Alias for setSize(const label, const T&)
|
||||
inline void resize(const label, const T&);
|
||||
inline void resize(const label newSize, const T& a);
|
||||
|
||||
//- Reset size of List
|
||||
void setSize(const label);
|
||||
void setSize(const label newSize);
|
||||
|
||||
//- Reset size of List and value for new elements
|
||||
void setSize(const label, const T&);
|
||||
void setSize(const label newSize, const T& a);
|
||||
|
||||
//- Clear the list, i.e. set size to zero
|
||||
inline void clear();
|
||||
|
||||
//- Append an element at the end of the list
|
||||
inline void append(const T&);
|
||||
inline void append(const T& t);
|
||||
|
||||
//- Append a List at the end of this list
|
||||
inline void append(const UList<T>&);
|
||||
inline void append(const UList<T>& lst);
|
||||
|
||||
//- Append a UIndirectList at the end of this list
|
||||
inline void append(const UIndirectList<T>&);
|
||||
inline void append(const UIndirectList<T>& lst);
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
// and annul the argument list
|
||||
void transfer(List<T>&);
|
||||
void transfer(List<T>& a);
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
// and annul the argument list
|
||||
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
||||
void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a);
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
// and annul the argument list
|
||||
void transfer(SortableList<T>&);
|
||||
void transfer(SortableList<T>& a);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<List<T>> xfer();
|
||||
|
||||
//- Return subscript-checked element of UList
|
||||
inline T& newElmt(const label);
|
||||
//- Return subscript-checked element of UList.
|
||||
// Resize list if required.
|
||||
inline T& newElmt(const label i);
|
||||
|
||||
|
||||
//- Disallow implicit shallowCopy
|
||||
@ -250,25 +258,25 @@ public:
|
||||
// Member operators
|
||||
|
||||
//- Assignment to UList operator. Takes linear time
|
||||
void operator=(const UList<T>&);
|
||||
void operator=(const UList<T>& a);
|
||||
|
||||
//- Assignment operator. Takes linear time
|
||||
void operator=(const List<T>&);
|
||||
void operator=(const List<T>& a);
|
||||
|
||||
//- Assignment to SLList operator. Takes linear time
|
||||
void operator=(const SLList<T>&);
|
||||
void operator=(const SLList<T>& lst);
|
||||
|
||||
//- Assignment to UIndirectList operator. Takes linear time
|
||||
void operator=(const UIndirectList<T>&);
|
||||
void operator=(const UIndirectList<T>& lst);
|
||||
|
||||
//- Assignment to BiIndirectList operator. Takes linear time
|
||||
void operator=(const BiIndirectList<T>&);
|
||||
void operator=(const BiIndirectList<T>& lst);
|
||||
|
||||
//- Assignment to an initializer list
|
||||
void operator=(std::initializer_list<T>);
|
||||
void operator=(std::initializer_list<T> lst);
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T&);
|
||||
inline void operator=(const T& t);
|
||||
|
||||
//- Assignment of all entries to zero
|
||||
inline void operator=(const zero);
|
||||
@ -278,7 +286,7 @@ public:
|
||||
|
||||
//- Read List from Istream, discarding contents of existing List
|
||||
friend Istream& operator>> <T>
|
||||
(Istream&, List<T>&);
|
||||
(Istream& is, List<T>& L);
|
||||
};
|
||||
|
||||
|
||||
@ -290,7 +298,7 @@ public:
|
||||
// \endcode
|
||||
// Mostly useful for handling command-line arguments
|
||||
template<class T>
|
||||
List<T> readList(Istream&);
|
||||
List<T> readList(Istream& is);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -77,8 +77,8 @@ template<class T>
|
||||
template<class InputIterator>
|
||||
inline Foam::List<T>::List
|
||||
(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
InputIterator begIter,
|
||||
InputIterator endIter,
|
||||
const label s
|
||||
)
|
||||
:
|
||||
@ -88,10 +88,11 @@ inline Foam::List<T>::List
|
||||
{
|
||||
alloc();
|
||||
|
||||
InputIterator iter = first;
|
||||
InputIterator iter = begIter;
|
||||
forAll(*this, i)
|
||||
{
|
||||
this->operator[](i) = *iter++;
|
||||
this->operator[](i) = *iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +127,7 @@ inline void Foam::List<T>::clear()
|
||||
if (this->v_)
|
||||
{
|
||||
delete[] this->v_;
|
||||
this->v_ = 0;
|
||||
this->v_ = nullptr;
|
||||
}
|
||||
|
||||
this->size_ = 0;
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::SortableList<T>::SortableList()
|
||||
inline Foam::SortableList<T>::SortableList()
|
||||
{}
|
||||
|
||||
|
||||
@ -51,14 +51,14 @@ Foam::SortableList<T>::SortableList(const Xfer<List<T>>& values)
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::SortableList<T>::SortableList(const label size)
|
||||
inline Foam::SortableList<T>::SortableList(const label size)
|
||||
:
|
||||
List<T>(size)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::SortableList<T>::SortableList(const label size, const T& val)
|
||||
inline Foam::SortableList<T>::SortableList(const label size, const T& val)
|
||||
:
|
||||
List<T>(size, val)
|
||||
{}
|
||||
@ -72,6 +72,20 @@ Foam::SortableList<T>::SortableList(const SortableList<T>& lst)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class InputIterator>
|
||||
inline Foam::SortableList<T>::SortableList
|
||||
(
|
||||
InputIterator begIter,
|
||||
InputIterator endIter
|
||||
)
|
||||
:
|
||||
List<T>(begIter, endIter)
|
||||
{
|
||||
sort();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::SortableList<T>::SortableList(std::initializer_list<T> values)
|
||||
:
|
||||
@ -140,9 +154,9 @@ Foam::Xfer<Foam::List<T>> Foam::SortableList<T>::xfer()
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::SortableList<T>::operator=(const T& t)
|
||||
inline void Foam::SortableList<T>::operator=(const T& val)
|
||||
{
|
||||
UList<T>::operator=(t);
|
||||
UList<T>::operator=(val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -65,27 +65,32 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Null constructor, sort later (eg, after assignment or transfer)
|
||||
SortableList();
|
||||
inline SortableList();
|
||||
|
||||
//- Construct from UList, sorting immediately
|
||||
explicit SortableList(const UList<T>&);
|
||||
explicit SortableList(const UList<T>& values);
|
||||
|
||||
//- Construct from transferred List, sorting immediately
|
||||
explicit SortableList(const Xfer<List<T>>&);
|
||||
explicit SortableList(const Xfer<List<T>>& values);
|
||||
|
||||
//- Construct given size. Sort later on
|
||||
// The indices remain empty until the list is sorted
|
||||
explicit SortableList(const label size);
|
||||
explicit inline SortableList(const label size);
|
||||
|
||||
//- Construct given size and initial value. Sort later on
|
||||
// The indices remain empty until the list is sorted
|
||||
SortableList(const label size, const T&);
|
||||
inline SortableList(const label size, const T& val);
|
||||
|
||||
//- Construct given begin/end iterators.
|
||||
// Uses std::distance to determine the size.
|
||||
template<class InputIterator>
|
||||
inline SortableList(InputIterator begIter, InputIterator endIter);
|
||||
|
||||
//- Construct as copy
|
||||
SortableList(const SortableList<T>&);
|
||||
inline SortableList(const SortableList<T>& lst);
|
||||
|
||||
//- Construct from an initializer list, sorting immediately
|
||||
SortableList(std::initializer_list<T>);
|
||||
SortableList(std::initializer_list<T> values);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -122,16 +127,16 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T&);
|
||||
inline void operator=(const T& val);
|
||||
|
||||
//- Assignment to UList operator. Takes linear time
|
||||
inline void operator=(const UList<T>&);
|
||||
inline void operator=(const UList<T>& lst);
|
||||
|
||||
//- Assignment operator. Takes linear time
|
||||
inline void operator=(const SortableList<T>&);
|
||||
inline void operator=(const SortableList<T>& lst);
|
||||
|
||||
//- Assignment to an initializer list
|
||||
void operator=(std::initializer_list<T>);
|
||||
void operator=(std::initializer_list<T> lst);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -91,9 +91,9 @@ Foam::IOobjectList::IOobjectList
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobjectList::IOobjectList(const IOobjectList& ioOL)
|
||||
Foam::IOobjectList::IOobjectList(const IOobjectList& iolist)
|
||||
:
|
||||
HashPtrTable<IOobject>(ioOL)
|
||||
HashPtrTable<IOobject>(iolist)
|
||||
{}
|
||||
|
||||
|
||||
@ -113,17 +113,7 @@ bool Foam::IOobjectList::add(IOobject& io)
|
||||
|
||||
bool Foam::IOobjectList::remove(IOobject& io)
|
||||
{
|
||||
HashPtrTable<IOobject>::iterator iter =
|
||||
HashPtrTable<IOobject>::find(io.name());
|
||||
|
||||
if (iter != end())
|
||||
{
|
||||
return erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return erase(io.name());
|
||||
}
|
||||
|
||||
|
||||
@ -131,7 +121,7 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
|
||||
{
|
||||
HashPtrTable<IOobject>::const_iterator iter = find(name);
|
||||
|
||||
if (iter != end())
|
||||
if (iter.found())
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
@ -152,68 +142,80 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRe& name) const
|
||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRe& matcher) const
|
||||
{
|
||||
IOobjectList objectsOfName(size());
|
||||
IOobjectList results(size());
|
||||
|
||||
forAllConstIter(HashPtrTable<IOobject>, *this, iter)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (name.match(iter()->name()))
|
||||
if (matcher.match(iter.key()))
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
InfoInFunction << "Found " << iter.key() << endl;
|
||||
}
|
||||
|
||||
objectsOfName.insert(iter.key(), new IOobject(*iter()));
|
||||
results.insert
|
||||
(
|
||||
iter.key(),
|
||||
new IOobject(*(iter.object()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return objectsOfName;
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordReList& patterns) const
|
||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordReList& matcher) const
|
||||
{
|
||||
wordReListMatcher names(patterns);
|
||||
wordReListMatcher mat(matcher);
|
||||
|
||||
IOobjectList objectsOfName(size());
|
||||
IOobjectList results(size());
|
||||
|
||||
forAllConstIter(HashPtrTable<IOobject>, *this, iter)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (names.match(iter()->name()))
|
||||
if (mat.match(iter.key()))
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
InfoInFunction << "Found " << iter.key() << endl;
|
||||
}
|
||||
|
||||
objectsOfName.insert(iter.key(), new IOobject(*iter()));
|
||||
results.insert
|
||||
(
|
||||
iter.key(),
|
||||
new IOobject(*(iter.object()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return objectsOfName;
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const
|
||||
Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& clsName) const
|
||||
{
|
||||
IOobjectList objectsOfClass(size());
|
||||
IOobjectList results(size());
|
||||
|
||||
forAllConstIter(HashPtrTable<IOobject>, *this, iter)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (iter()->headerClassName() == ClassName)
|
||||
if (iter()->headerClassName() == clsName)
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
InfoInFunction << "Found " << iter.key() << endl;
|
||||
}
|
||||
|
||||
objectsOfClass.insert(iter.key(), new IOobject(*iter()));
|
||||
results.insert
|
||||
(
|
||||
iter.key(),
|
||||
new IOobject(*(iter.object()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return objectsOfClass;
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
@ -231,33 +233,33 @@ Foam::wordList Foam::IOobjectList::sortedNames() const
|
||||
|
||||
Foam::wordList Foam::IOobjectList::names
|
||||
(
|
||||
const word& ClassName
|
||||
const word& clsName
|
||||
) const
|
||||
{
|
||||
wordList objectNames(size());
|
||||
wordList objNames(size());
|
||||
|
||||
label count = 0;
|
||||
forAllConstIter(HashPtrTable<IOobject>, *this, iter)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (iter()->headerClassName() == ClassName)
|
||||
if (iter()->headerClassName() == clsName)
|
||||
{
|
||||
objectNames[count++] = iter.key();
|
||||
objNames[count++] = iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
objectNames.setSize(count);
|
||||
objNames.setSize(count);
|
||||
|
||||
return objectNames;
|
||||
return objNames;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::names
|
||||
(
|
||||
const word& ClassName,
|
||||
const word& clsName,
|
||||
const wordRe& matcher
|
||||
) const
|
||||
{
|
||||
wordList objNames = names(ClassName);
|
||||
wordList objNames = names(clsName);
|
||||
|
||||
return wordList(objNames, findStrings(matcher, objNames));
|
||||
}
|
||||
@ -265,11 +267,11 @@ Foam::wordList Foam::IOobjectList::names
|
||||
|
||||
Foam::wordList Foam::IOobjectList::names
|
||||
(
|
||||
const word& ClassName,
|
||||
const word& clsName,
|
||||
const wordReList& matcher
|
||||
) const
|
||||
{
|
||||
wordList objNames = names(ClassName);
|
||||
wordList objNames = names(clsName);
|
||||
|
||||
return wordList(objNames, findStrings(matcher, objNames));
|
||||
}
|
||||
@ -277,10 +279,10 @@ Foam::wordList Foam::IOobjectList::names
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames
|
||||
(
|
||||
const word& ClassName
|
||||
const word& clsName
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(ClassName);
|
||||
wordList sortedLst = names(clsName);
|
||||
sort(sortedLst);
|
||||
|
||||
return sortedLst;
|
||||
@ -289,11 +291,11 @@ Foam::wordList Foam::IOobjectList::sortedNames
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames
|
||||
(
|
||||
const word& ClassName,
|
||||
const word& clsName,
|
||||
const wordRe& matcher
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(ClassName, matcher);
|
||||
wordList sortedLst = names(clsName, matcher);
|
||||
sort(sortedLst);
|
||||
|
||||
return sortedLst;
|
||||
@ -302,11 +304,11 @@ Foam::wordList Foam::IOobjectList::sortedNames
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames
|
||||
(
|
||||
const word& ClassName,
|
||||
const word& clsName,
|
||||
const wordReList& matcher
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(ClassName, matcher);
|
||||
wordList sortedLst = names(clsName, matcher);
|
||||
sort(sortedLst);
|
||||
|
||||
return sortedLst;
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
IOobjectList(const IOobjectList&);
|
||||
IOobjectList(const IOobjectList& iolist);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -87,52 +87,56 @@ public:
|
||||
// Member functions
|
||||
|
||||
//- Add an IOobject to the list
|
||||
bool add(IOobject&);
|
||||
bool add(IOobject& io);
|
||||
|
||||
//- Remove an IOobject from the list
|
||||
bool remove(IOobject&);
|
||||
bool remove(IOobject& io);
|
||||
|
||||
//- Lookup a given name and return IOobject ptr if found else nullptr
|
||||
IOobject* lookup(const word& name) const;
|
||||
|
||||
//- Return the list for all IOobects whose name matches name
|
||||
IOobjectList lookup(const wordRe& name) const;
|
||||
//- The list of all IOobects with matching names
|
||||
IOobjectList lookup(const wordRe& matcher) const;
|
||||
|
||||
//- Return the list for all IOobects whose name matches name
|
||||
IOobjectList lookup(const wordReList& patterns) const;
|
||||
//- The list of all IOobjects with matching names
|
||||
IOobjectList lookup(const wordReList& matcher) const;
|
||||
|
||||
//- Return the list for all IOobjects of a given class
|
||||
IOobjectList lookupClass(const word& className) const;
|
||||
//- The list of all IOobjects with the given class name
|
||||
IOobjectList lookupClass(const word& clsName) const;
|
||||
|
||||
|
||||
//- A list of names of the IOobjects
|
||||
wordList names() const;
|
||||
|
||||
//- A list of names of IOobjects of the given class
|
||||
wordList names(const word& className) const;
|
||||
//- The names of IOobjects with the given class name
|
||||
wordList names(const word& clsName) const;
|
||||
|
||||
//- A list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matcher
|
||||
wordList names(const word& className, const wordRe&) const;
|
||||
//- The names of IOobjects with the given class name that also
|
||||
// have a name satisfying the input matcher
|
||||
wordList names(const word& clsName, const wordRe& matcher) const;
|
||||
|
||||
//- A list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matchers
|
||||
wordList names(const word& className, const wordReList&) const;
|
||||
//- The names of IOobjects with the given class name that also
|
||||
// have a name satisfying the input matcher
|
||||
wordList names(const word& clsName, const wordReList& matcher) const;
|
||||
|
||||
|
||||
//- A sorted list of names of the IOobjects
|
||||
wordList sortedNames() const;
|
||||
|
||||
//- A sorted list of names of IOobjects of given class
|
||||
wordList sortedNames(const word& className) const;
|
||||
//- The sorted names of IOobjects with the given class name
|
||||
wordList sortedNames(const word& clsName) const;
|
||||
|
||||
//- A sorted list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matcher
|
||||
wordList sortedNames(const word& className, const wordRe&) const;
|
||||
//- The sorted names of IOobjects with the given class name that also
|
||||
// have a name satisfying the input matcher
|
||||
wordList sortedNames(const word& clsName, const wordRe& matcher) const;
|
||||
|
||||
//- A sorted list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matchers
|
||||
wordList sortedNames(const word& className, const wordReList&) const;
|
||||
//- The sorted names of IOobjects with the given class name that also
|
||||
// have a name satisfying the input matcher
|
||||
wordList sortedNames
|
||||
(
|
||||
const word& clsName,
|
||||
const wordReList& matcher
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
|
||||
bool Foam::dictionary::findInPatterns
|
||||
(
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
const word& keyword,
|
||||
DLList<entry*>::const_iterator& wcLink,
|
||||
DLList<autoPtr<regExp>>::const_iterator& reLink
|
||||
) const
|
||||
@ -173,8 +173,8 @@ bool Foam::dictionary::findInPatterns
|
||||
if
|
||||
(
|
||||
patternMatch
|
||||
? reLink()->match(Keyword)
|
||||
: wcLink()->keyword() == Keyword
|
||||
? reLink()->match(keyword)
|
||||
: wcLink()->keyword() == keyword
|
||||
)
|
||||
{
|
||||
return true;
|
||||
@ -192,7 +192,7 @@ bool Foam::dictionary::findInPatterns
|
||||
bool Foam::dictionary::findInPatterns
|
||||
(
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
const word& keyword,
|
||||
DLList<entry*>::iterator& wcLink,
|
||||
DLList<autoPtr<regExp>>::iterator& reLink
|
||||
)
|
||||
@ -204,8 +204,8 @@ bool Foam::dictionary::findInPatterns
|
||||
if
|
||||
(
|
||||
patternMatch
|
||||
? reLink()->match(Keyword)
|
||||
: wcLink()->keyword() == Keyword
|
||||
? reLink()->match(keyword)
|
||||
: wcLink()->keyword() == keyword
|
||||
)
|
||||
{
|
||||
return true;
|
||||
@ -951,11 +951,11 @@ void Foam::dictionary::set(const keyType& k, const dictionary& d)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dictionary::remove(const word& Keyword)
|
||||
bool Foam::dictionary::remove(const word& keyword)
|
||||
{
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find(Keyword);
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
|
||||
|
||||
if (iter != hashedEntries_.end())
|
||||
if (iter.found())
|
||||
{
|
||||
// Delete from patterns first
|
||||
DLList<entry*>::iterator wcLink =
|
||||
@ -964,7 +964,7 @@ bool Foam::dictionary::remove(const word& Keyword)
|
||||
patternRegexps_.begin();
|
||||
|
||||
// Find in pattern using exact match only
|
||||
if (findInPatterns(false, Keyword, wcLink, reLink))
|
||||
if (findInPatterns(false, keyword, wcLink, reLink))
|
||||
{
|
||||
patternEntries_.remove(wcLink);
|
||||
patternRegexps_.remove(reLink);
|
||||
|
||||
@ -204,7 +204,7 @@ class dictionary
|
||||
bool findInPatterns
|
||||
(
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
const word& keyword,
|
||||
DLList<entry*>::const_iterator& wcLink,
|
||||
DLList<autoPtr<regExp>>::const_iterator& reLink
|
||||
) const;
|
||||
@ -213,7 +213,7 @@ class dictionary
|
||||
bool findInPatterns
|
||||
(
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
const word& keyword,
|
||||
DLList<entry*>::iterator& wcLink,
|
||||
DLList<autoPtr<regExp>>::iterator& reLink
|
||||
);
|
||||
@ -518,7 +518,7 @@ public:
|
||||
void set(const keyType& k, const T& t);
|
||||
|
||||
//- Remove an entry specified by keyword
|
||||
bool remove(const word& Keyword);
|
||||
bool remove(const word& keyword);
|
||||
|
||||
//- Change the keyword for an entry,
|
||||
// optionally forcing overwrite of an existing entry
|
||||
|
||||
@ -57,7 +57,7 @@ class dictionary;
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class entry;
|
||||
Ostream& operator<<(Ostream&, const entry&);
|
||||
Ostream& operator<<(Ostream& os, const entry& e);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class entry Declaration
|
||||
@ -75,11 +75,16 @@ class entry
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Get the next valid keyword. Return true if is valid keyType.
|
||||
static bool getKeyword(keyType&, token&, Istream&);
|
||||
//- Get the next valid keyword. Return true if a valid keyType.
|
||||
static bool getKeyword
|
||||
(
|
||||
keyType& keyword,
|
||||
token& keywordToken,
|
||||
Istream& is
|
||||
);
|
||||
|
||||
//- Get the next valid keyword otherwise return false
|
||||
static bool getKeyword(keyType&, Istream&);
|
||||
static bool getKeyword(keyType& keyword, Istream& is);
|
||||
|
||||
|
||||
public:
|
||||
@ -90,10 +95,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from keyword
|
||||
entry(const keyType&);
|
||||
entry(const keyType& keyword);
|
||||
|
||||
//- Construct as copy
|
||||
entry(const entry&);
|
||||
entry(const entry& e);
|
||||
|
||||
//- Construct on freestore as copy with reference to the
|
||||
// dictionary the copy belongs to
|
||||
@ -107,7 +112,7 @@ public:
|
||||
virtual autoPtr<entry> clone() const;
|
||||
|
||||
//- Construct from Istream and insert into dictionary
|
||||
static bool New(dictionary& parentDict, Istream&);
|
||||
static bool New(dictionary& parentDict, Istream& is);
|
||||
|
||||
//- Construct on freestore from Istream and return
|
||||
static autoPtr<entry> New(Istream& is);
|
||||
@ -179,7 +184,7 @@ public:
|
||||
|
||||
// Ostream operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const entry&);
|
||||
friend Ostream& operator<<(Ostream& os, const entry& e);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
|
||||
|
||||
bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
{
|
||||
is.fatalCheck("entry::New(const dictionary& parentDict, Istream&)");
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
keyType keyword;
|
||||
token keyToken;
|
||||
@ -324,7 +324,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
|
||||
Foam::autoPtr<Foam::entry> Foam::entry::New(Istream& is)
|
||||
{
|
||||
is.fatalCheck("entry::New(Istream&)");
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
keyType keyword;
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@ namespace Foam
|
||||
int labelRange::debug(debug::debugSwitch("labelRange", 0));
|
||||
}
|
||||
|
||||
const Foam::labelRange Foam::labelRange::null;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ SourceFiles
|
||||
#define labelRange_H
|
||||
|
||||
#include "label.H"
|
||||
#include <iterator>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -63,26 +64,32 @@ class labelRange
|
||||
|
||||
public:
|
||||
|
||||
static int debug;
|
||||
// Static Data Members
|
||||
|
||||
static int debug;
|
||||
|
||||
//- An empty range with start=0, size=0.
|
||||
static const labelRange null;
|
||||
|
||||
|
||||
// STL type definitions similar to what UList has
|
||||
|
||||
//- Type of values the range contains
|
||||
typedef label value_type;
|
||||
|
||||
//- The type that can represent the difference between two iterators
|
||||
typedef label difference_type;
|
||||
|
||||
//- The type that can represent the size of the range
|
||||
typedef label size_type;
|
||||
|
||||
// Forward declaration
|
||||
class const_iterator;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- An empty range with zero for start/size.
|
||||
inline labelRange();
|
||||
|
||||
//- Construct a range from start and size, enforcing non-negative size.
|
||||
//- Construct a range from start/size, enforcing non-negative size.
|
||||
// Optionally adjust the start to avoid any negative indices.
|
||||
inline labelRange
|
||||
(
|
||||
@ -95,6 +102,12 @@ public:
|
||||
labelRange(Istream& is);
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- An identity range with range[i] == i.
|
||||
inline static labelRange identity(const label len);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Adjust start position
|
||||
@ -184,6 +197,9 @@ public:
|
||||
//- Return element in the range, no bounds checking
|
||||
inline label operator[](const label localIndex) const;
|
||||
|
||||
//- Return const_iterator to element in the range
|
||||
inline const_iterator operator()(const label localIndex) const;
|
||||
|
||||
//- Increase the size by 1.
|
||||
inline label operator++();
|
||||
inline label operator++(int);
|
||||
@ -197,21 +213,30 @@ public:
|
||||
|
||||
//- Forward iterator with const access
|
||||
class const_iterator
|
||||
:
|
||||
public std::iterator
|
||||
<
|
||||
std::input_iterator_tag,
|
||||
label,
|
||||
label,
|
||||
const label*,
|
||||
const label&
|
||||
>
|
||||
{
|
||||
//- The current label (not the local index)
|
||||
label index_;
|
||||
//- The current (global) value
|
||||
label value_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from range at given local index.
|
||||
// A negative index signals the 'end' position
|
||||
inline const_iterator(const labelRange* range, const label i = 0);
|
||||
// A negative index is invalid and corresponds to the 'end'
|
||||
inline const_iterator(const labelRange* range, const label i=0);
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return the current label
|
||||
//- Return the current (global) value
|
||||
inline label operator*() const;
|
||||
|
||||
inline const_iterator& operator++();
|
||||
|
||||
@ -64,7 +64,7 @@ inline Foam::labelRange::const_iterator::const_iterator
|
||||
const label i
|
||||
)
|
||||
:
|
||||
index_
|
||||
value_
|
||||
(
|
||||
range->start()
|
||||
+ ((i < 0 || i > range->size()) ? range->size() : i)
|
||||
@ -74,14 +74,14 @@ inline Foam::labelRange::const_iterator::const_iterator
|
||||
|
||||
inline Foam::label Foam::labelRange::const_iterator::operator*() const
|
||||
{
|
||||
return index_;
|
||||
return value_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::labelRange::const_iterator&
|
||||
Foam::labelRange::const_iterator::operator++()
|
||||
{
|
||||
++index_;
|
||||
++value_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ inline Foam::labelRange::const_iterator
|
||||
Foam::labelRange::const_iterator::operator++(int)
|
||||
{
|
||||
const_iterator old = *this;
|
||||
++index_;
|
||||
++value_;
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ inline bool Foam::labelRange::const_iterator::operator==
|
||||
const const_iterator& iter
|
||||
) const
|
||||
{
|
||||
return (this->index_ == iter.index_);
|
||||
return (this->value_ == iter.value_);
|
||||
}
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ inline bool Foam::labelRange::const_iterator::operator!=
|
||||
const const_iterator& iter
|
||||
) const
|
||||
{
|
||||
return (this->index_ != iter.index_);
|
||||
return (this->value_ != iter.value_);
|
||||
}
|
||||
|
||||
|
||||
@ -139,6 +139,12 @@ inline const Foam::labelRange::const_iterator Foam::labelRange::cend() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::labelRange Foam::labelRange::identity(const label len)
|
||||
{
|
||||
return labelRange(0, len);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::labelRange::setStart(const label i)
|
||||
{
|
||||
start_ = i;
|
||||
@ -264,6 +270,13 @@ inline Foam::label Foam::labelRange::operator[](const label localIndex) const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::labelRange::const_iterator
|
||||
Foam::labelRange::operator()(const label localIndex) const
|
||||
{
|
||||
return const_iterator(this, localIndex);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::labelRange::operator++()
|
||||
{
|
||||
return ++size_;
|
||||
|
||||
Reference in New Issue
Block a user