- changes the addressed list size without affecting list allocation.
Can be useful for the following type of coding pattern:
- pre-allocate a List with some max content length
- populate with some content (likely not the entire pre-allocated size)
- truncate the list to the length of valid content
- process the List
- discard the List
Since the List is being discarded, using resize_unsafe() instead of
resize() avoids an additional allocation with the new size and
copying/moving of the elements.
This programming pattern can also be used when the List is being
returned from a subroutine, and carrying about a bit of unused memory
is less important than avoiding reallocation + copy/move.
If used improperly, it can obviously result in addressing into
unmanaged memory regions (ie, 'unsafe').
This class is largely a pre-C++11 holdover. It is now possible to
simply use move construct/assignment directly.
In a few rare cases (eg, polyMesh::resetPrimitives) it has been
replaced by an autoPtr.
- improve functional compatibility with DynList (remove methods)
* eg, remove an element from any position in a DynamicList
* reduce the number of template parameters
* remove/subset regions of DynamicList
- propagate Swap template specializations for lists, hashtables
- move construct/assignment to various containers.
- add find/found methods for FixedList and UList for a more succinct
(and clearer?) usage than the equivalent global findIndex() function.
- simplify List_FOR_ALL loops
DynamicList
-----------
- construction, assignment and append
HashSet
-------
- construction, insert, set.
- assignment will use the implicit List constructor
hashedWordList
--------------
- construction, assignment
- additional sort() and uniq() methods.
- Readonly access to HashTable information via lookup() method.
- NB: could avoid 'const char**' constructors in the future
- The capitalization is consistent with most other template classes, but
more importantly frees up xfer() for use as method name without needing
special treatment to avoid ambiguities.
It seems reasonable to have different names for transfer(...) and xfer()
methods, since the transfer is occuring in different directions.
The xfer() method can thus replace the recently introduced zero-parameter
transfer() methods.
Other name candidates (eg, yield, release, etc.) were deemed too abstract.
- this should provide a slightly more naturally means to using transfer
constructors, for example
labelList list2(list1.transfer());
vs. labelList list2(xferMove(list1));
- returns a plain list where appropriate (eg, DynamicList, SortableList)
for example
labelList list2(dynList1.transfer());
vs. labelList list2(xferMoveTo<labelList>(dynList1));
- setSize() adjusts the addressable length only.
Changed setSize(label) usage to setCapacity(label) or reserve(label)
throughout. The final name (capacity vs. storageSize() vs. whatever) can
easily be decided at a later date.
- added setSize(label, const T&), which may still not be really useful, but
is at least now meaningful
- made shrink() a bit more legible.
- added append(UList<T>&)
- copying from a UList avoids reallocations where possible
The following bits of code continue to use the DynamicList::setSize(), but
appear to be legitimate (or the corresponding code itself needs rethinking).
src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointCells.C:167: error: within this context
src/OpenFOAM/lnInclude/faceTemplates.C:44: error: within this context
src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C:178: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:737: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:741: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:745: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:749: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:754: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:935: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:940: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:1041: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:1046: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2161: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2162: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2201: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2205: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2261: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2262: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2263: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2264: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2265: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3011: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3076: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3244: error: within this context
src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3371: error: within this context
src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:73: error: within this context
src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:91: error: within this context
src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:73: error: within this context
src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:91: error: within this context
* DynamicList::allocSize(label)
- Adjust the allocated size. The addressed list can be truncated but not
extended, use setSize() for that.
* DynamicList::reserve(label)
- Reserve allocation for *at least* this number of elements.
Never shrinks the allocated size, nor touches the addressed list size.
* DynamicList::setSize(label)
- proposed behaviour:
Adjust the addressed list size, allocating extra space if required.
- The current behaviour is ambiguous about what addressable size will
actually get set and using it to extend the addressable size (as
per List) automatically shrinks the allocated space to this size!