Commit Graph

29 Commits

Author SHA1 Message Date
Mark Olesen
4f43f0302d ENH: additional Map/HashTable constructors and ListOp functions
- construct Map/HashTable from key/value lists.

- invertToMap() : like invert() but returns a Map<label>,
  which is useful for sparse numbering

- inplaceRenumber() : taking a Map<label> for the mapper

ENH: construct/reset CStringList for list of C-strings
2024-02-23 18:10:48 +01:00
Mark Olesen
375a4792f9 ENH: HashSet, HashTable, HashPtrTable merge() method
- name and functionality similar to std::unordered_map (C++17).
  Formalizes what had been previously been implemented in IOobjectList
  but now manages without pointer deletion/creation.
2023-02-13 21:22:20 +01:00
Mark Olesen
4110699d90 ENH: HashTable::emplace_set() method, HashPtrTable support for unique_ptr
- forwarding like the emplace() method, but overwriting existing
  entries as required

- propagate similar changes to HashPtrTable

  For example, with HashPtrTable<labelList> table(...) :

  With 'insert' semantics

      table.emplace("list1", 1000);

  vs
      if (!table.found("list1"))
      {
          table.set("list1", new labelList(1000));
      }
  or
      table.insert("list1", autoPtr<labelList>::New(1000));

  Note that the last example invokes an unnecessary allocation/deletion
  if the insertion is unsuccessful.

  With 'set' semantics:

      table.emplace_set("list1", 15);

  vs
      table.set("list1", new labelList(15));
2020-07-28 08:40:43 +02:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
b6bf9129f6 DEFEATURE: pointer dereferencing for HashTable iterator
- this largely reverts 3f0f218d88 and 4ee65d12c4.

  Consistent addressing with support for wrapped pointer types (eg,
  autoPtr, std::unique_ptr) has proven to be less robust than desired.
  Thus rescind HashTable iterator '->' dereferencing (from APR-2019).
2019-09-27 19:45:54 +02:00
Mark Olesen
3c07a1bb6f ENH: Foam::name() of memory address
- returns the memory address formatted in hexadecimal, which can be
  useful for detailed information
2019-08-12 10:46:29 +02:00
Mark Olesen
bbc2d4a8b0 ENH: HashTable and HashSet improvements
- unfriend HashSet, HashTable IO operators

- global min(), max(), minMax() functions taking a labelHashSet and an
  optional limit. For example,

      labelHashSet set = ...;

      Info<< "min is " << min(set) << nl;
      Info<< "max (non-negative) " << max(set, 0) << nl;

- make HashTable iterator '->' dereferencing more consistent by also
  supporting non-pointer types as well.

- read HashTable values in-situ to avoid copying
2019-07-12 18:00:00 +02: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
59da4cf56d STYLE: use uintptr_t cast instead of long when reporting addresses 2019-04-29 08:15:48 +02:00
Mark Olesen
39c91d8440 ENH: support HashTable iterator pointer dereference 2019-04-06 16:00:21 +02:00
Mark Olesen
e9323ecbbb STYLE: use finiteVolume in Make/options placeholder 2019-02-24 17:32:13 +01:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
mattijs
3b6027d1be ENH: test: make test apps compile. Fixes #876. 2018-06-14 15:14:14 +01:00
Mark Olesen
03b287ed24 COMP: adjust tests to compile with current code base 2018-02-20 17:24:08 +01:00
Henry Weller
076c4c6e82 HashTable: Added C++11 initializer_list constructor
e.g.
    HashTable<label, string> table1
    {
        {"kjhk", 10},
        {"kjhk2", 12}
    };

    HashTable<label, label, Hash<label>> table2
    {
        {3, 10},
        {5, 12},
        {7, 16}
    };
2016-08-05 22:30:26 +01:00
Henry Weller
56fa7c0906 Update code to use the simpler C++11 template syntax removing spaces between closing ">"s 2016-01-10 22:41:16 +00:00
Henry
c2dd153a14 Copyright transfered to the OpenFOAM Foundation 2011-08-14 12:17:30 +01:00
Mark Olesen
129695a950 STYLE: adjust executable names for some tests 2011-01-19 14:29:56 +01:00
andy
eaef8d482b STYLE: Updated 1991 start copyright year to 2004 2011-01-14 16:08:00 +00:00
andy
099cc39e2e Revert "STYLE: 2011 copyright date."
This reverts commit b18f6cc1ce.
2011-01-05 18:24:29 +00:00
graham
b18f6cc1ce STYLE: 2011 copyright date. 2011-01-05 11:14:26 +00:00
graham
012494fdb5 STYLE: Fixing code style requirements for all apps.
Exception: applyWallFunctionBoundaryConditions.C cannot split #include
directives.
2010-07-27 15:27:05 +01:00
Mark Olesen
d29c438657 STYLE: use url for FSF license instead of postal address, switch to GPL v3 2010-03-29 14:07:56 +02:00
Mark Olesen
19503c93e1 rename xfer<T> class to Xfer<T>
- 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.
2009-01-05 12:30:19 +01:00
Mark Olesen
a010121427 HashTable / StaticHashTable changes
StaticHashTable:
- erase(iterator&) now actually alters the iterator and iterator++() handles
  it properly
- clear() also sets count to zero
- operator=(const StaticHashTable&) doesn't crash after a previous transfer
- operator(), operator==() and operator!=() added

HashTable:
- operator=(const HashTable&) gets tableSize if required, eg, after a
  previous transfer)

HashSet / Map
- add xfer<...> constructor for underlying HashTable
2009-01-02 13:24:30 +01:00
Mark Olesen
28b200bcd9 update copyrights for 2009 2008-12-31 19:01:56 +01:00
Mark Olesen
02cabc3cf2 updated Copyright (C) \d+-2008 OpenCFD Ltd. 2008-06-25 15:01:46 +02:00
OpenFOAM-admin
3170c7c0c9 Creation of OpenFOAM-dev repository 15/04/2008 2008-04-15 18:56:58 +01:00