Commit Graph

6 Commits

Author SHA1 Message Date
Mark Olesen
eb8b51b475 ENH: use back(), pop_back() instead remove()
- adjust looping to resemble LIFO pattern

STYLE: adjust some string includes
2023-01-27 09:50:46 +01:00
Mark Olesen
95cd8ee75c ENH: improve hashing overloads of string-types and HashTable/HashSet
- additional dummy template parameter to assist with supporting
  derived classes. Currently just used for string types, but can be
  extended.

- provide hash specialization for various integer types.
  Removes the need for any forwarding.

- change default hasher for HashSet/HashTable from 'string::hash'
  to `Hash<Key>`. This avoids questionable hashing calls and/or
  avoids compiler resolution problems.

  For example,
  HashSet<label>::hasher and labelHashSet::hasher now both properly
  map to Hash<label> whereas previously HashSet<label> would have
  persistently mapped to string::hash, which was incorrect.

- standardize internal hashing functors.

  Functor name is 'hasher', as per STL set/map and the OpenFOAM
  HashSet/HashTable definitions.

  Older code had a local templated name, which added unnecessary
  clutter and the template parameter was always defaulted.
  For example,

      Old:  `FixedList<label, 3>::Hash<>()`
      New:  `FixedList<label, 3>::hasher()`
      Unchanged:  `labelHashSet::hasher()`

  Existing `Hash<>` functor namings are still supported,
  but deprecated.

- define hasher and Hash specialization for bitSet and PackedList

- add symmetric hasher for 'face'.
  Starts with lowest vertex value and walks in the direction
  of the next lowest value. This ensures that the hash code is
  independent of face orientation and face rotation.

NB:
  - some of keys for multiphase handling (eg, phasePairKey)
    still use yet another function naming: `hash` and `symmHash`.
    This will be targeted for alignment in the future.
2021-04-19 16:33:42 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
ac317699d8 ENH: additional HashTable emplace/insert/set methods (#1286)
- support move insert/set and emplace insertion.

  These adjustments can be used for improved memory efficiency, and
  allow hash tables of non-copyable objects (eg, std::unique_ptr).

- extend special HashTable output treatment to include pointer-like
  objects such as autoPtr and unique_ptr.

ENH: HashTable::at() method with checking. Fatal if entry does not exist.
2019-05-06 08:34:39 +02:00
Mark Olesen
10b69fa2b4 ENH: ListOp::inplaceMapValue using a Map<label> for the mapping.
For example, with some HashTable or Map container of models

    { model0 => 1, model1 => 4, model2 => 5, model3 => 12, model4 => 15, }

specify the remapping

    Map<label> mapper({{1, 3}, {2, 6}, {3, 12}, {5, 8}});

inplaceMapValue(mapper, models) then yields

    { model0 => 3, model1 => 4, model2 => 8, model3 => 12, model4 => 15, }

--

ENH: extend bitSet::count() to optionally count unset bits instead.

--

ENH: BitOps compatibility methods for boolList.

- These ease coding that uses a boolList instead of bitSet and use
  short-circuit logic when possible.

  Eg, when 'bitset' and 'bools' contain the same information

      bitset.count()  <->  BitOps::count(bools)
      bitset.all()    <->  BitOps::all(bools)
      bitset.any()    <->  BitOps::any(bools)
      bitset.none()   <->  BitOps::none(bools)

  These methods can then be used directly in parameters or in logic.
  Eg,

      returnReduce(bitset.any(), orOp<bool>());
      returnReduce(BitOps::any(bools), orOp<bool>());

      if (BitOps::any(bools)) ...
2018-04-27 10:43:32 +02:00
Mark Olesen
049617d037 ENH: update List and DynamicList methods (issue #595)
- 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
2017-09-20 17:20:54 +02:00