Skip to content
Snippets Groups Projects
  1. Feb 16, 2021
  2. Jul 27, 2020
  3. Nov 11, 2019
  4. Oct 31, 2019
  5. Nov 05, 2019
  6. May 06, 2019
    • Mark OLESEN's avatar
      ENH: additional HashTable emplace/insert/set methods (#1286) · ac317699
      Mark OLESEN authored
      - 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.
      ac317699
  7. Feb 06, 2019
  8. Jan 08, 2019
    • Mark OLESEN's avatar
    • Mark OLESEN's avatar
      ENH: partial reorganization of HashTable internals (#1160) · 8eefc7b3
      Mark OLESEN authored
      - relocate the pair_entry (HashTable) and unary_entry (HashSet) into
        the Detail namespace and add output handling.
      
        The output handling at this level removes the reliance on zero::null
        output (HashSet) and allows direct support of pointers.
        This means that the following now works
      
            HashTable<T*> tbl;
            os << tbl;
      
        It also means that we don't need to overload operator<< for
        HashPtrTable anymore.
      
      - avoid delete/new when calling HashSet::set(). If the entry already
        exists there is no reason to remove it and add another one with the
        same content.
      
      STYLE: HashTable iterators now have a val() method
      
      - identical to the object() iterator method, but shorter to type.
      8eefc7b3
  9. May 29, 2018
  10. May 17, 2018
    • Mark OLESEN's avatar
      ENH: avoid memory leaks for HashPtrTable, PtrMap insertion (issue #749) · 48d654cf
      Mark OLESEN authored
      - disallow insert() of raw pointers, since a failed insertion
        (ie, entry already existed) results in an unmanaged pointer.
      
        Either insert using an autoPtr, or set() with raw pointers or autoPtr.
      
      - IOobjectList::add() now takes an autoPtr instead of an object reference
      
      - IOobjectList::remove() now returns an autoPtr instead of a raw pointer
      48d654cf
  11. Mar 14, 2018
  12. Feb 08, 2018
  13. Jan 25, 2018
    • Mark OLESEN's avatar
      ENH: remove Foam::Swap specializations for HashSet, HashTable · 915e8c9f
      Mark OLESEN authored
      - without these will use the normal move construct + move assign.
        This is similarly efficient, but avoids the inadvertently having the
        incorrect Swap being used for derived classes.
      
      STYLE: remove unused xfer methods for HashTable, HashSet
      
      - unneeded since move construct and move assignment are possible
      915e8c9f
  14. Jan 23, 2018
  15. Oct 31, 2017
    • Mark OLESEN's avatar
      ENH: improvements to HashTable internals · 053a648e
      Mark OLESEN authored
      - make single-parameter construct (label) explicit
      - consolidate iterators
      - slightly reduced overhead for some HashSet types
      - improved resizing behaviour
      - compact output for empty Ptr hashes
      053a648e
  16. Oct 27, 2017
    • Mark OLESEN's avatar
      ENH: allow passing of comparator to sortToc methods · 0a62fd2f
      Mark OLESEN authored
      - this increases the flexibility of the interface
      
      - Add stringOps 'natural' string sorting comparison.
        Digits are sorted in their natural order, which means that
            (file10.txt file05.txt file2.txt)
        are sorted as
            (file2.txt file05.txt file10.txt)
      
      STYLE: consistent naming of template parameters for comparators
      
        - Compare for normal binary predicates
        - ListComparePredicate for list compare binary predicates
      0a62fd2f
  17. Sep 20, 2017
    • Mark OLESEN's avatar
      ENH: update List and DynamicList methods (issue #595) · 049617d0
      Mark OLESEN authored
      - 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
      049617d0
  18. May 29, 2017
  19. May 26, 2017
    • Mark OLESEN's avatar
      ENH: HashTable cfind() method returning a const_iterator · b8300759
      Mark OLESEN authored
      - This follows the same idea as cbegin/cend and is helpful when using
        C++11 auto to ensure we have unambiguous const-safe access.
      
        Previously:
        ====
          typename someLongClass::const_iterator iter = someTable.find(key);
      
          ... later on:
          *iter = value; // Oops, but caught by compiler.
      
        We can save some typing with auto, but it is uncertain what we get:
        ====
          auto iter = someTable.find(key);
              // iterator or const_iterator?
              // depends on someTable having const or non-const access.
      
          ... later on:
          *iter = value;  // Oops, but not caught by compiler.
      
        Using cfind instead, auto will deduce const_iterator as the type:
        ====
          auto iter = someTable.cfind(key);  // definitely const_iterator
      
          ... later on:
          *iter = value; // Oops, but caught by compiler.
      b8300759
  20. May 17, 2017
    • Mark OLESEN's avatar
      ENH: added HashTable count, filter and generalized toc methods · cf889306
      Mark OLESEN authored
      - Generalized means over filtering table entries based on their keys,
        values, or both.  Either filter (retain), or optionally prune elements
        that satisfy the specified predicate.
      
        filterKeys and filterValues:
        - Take a unary predicate with the signature
      
              bool operator()(const Key& k);
      
        - filterEntries:
          Takes a binary predicate with the signature
      
              bool operator()(const Key& k, const T& v);
      
      ==
      
        The predicates can be normal class methods, or provide on-the-fly
        using a C++ lambda. For example,
      
            wordRes goodFields = ...;
            allFieldNames.filterKeys
            (
                [&goodFields](const word& k){ return goodFields.match(k); }
            );
      
        Note that all classes that can match a string (eg, regExp, keyType,
        wordRe, wordRes) or that are derived from a Foam::string (eg, fileName,
        word) are provided with a corresponding
      
            bool operator()(const std::string&)
      
        that either performs a regular expression or a literal match.
        This allows such objects to be used directly as a unary predicate
        when filtering any string hash keys.
      
        Note that HashSet and hashedWordList both have the proper
        operator() methods that also allow them to be used as a unary
        predicate.
      
      - Similar predicate selection with the following:
          * tocKeys, tocValues, tocEntries
          * countKeys, countValues, countEntries
      
        except that instead of pruning, there is a simple logic inversion.
      cf889306
  21. May 15, 2017
  22. May 11, 2017
    • Mark OLESEN's avatar
      ENH: added HashTable 'lookup' and 'retain' methods · f73b5b62
      Mark OLESEN authored
      - lookup(): with a default value (const access)
        For example,
            Map<label> something;
            value = something.lookup(key, -1);
      
          being equivalent to the following:
      
            Map<label> something;
            value = -1;  // bad value
            if (something.found(key))
            {
                value = something[key];
            }
      
          except that lookup also makes it convenient to handle const references.
          Eg,
      
            const labelList& ids = someHash.lookup(key, labelList());
      
      - For consistency, provide a two parameter HashTable '()' operator.
        The lookup() method is, however, normally preferable when
        const-only access is to be ensured.
      
      - retain(): the counterpart to erase(), it only retains entries
        corresponding to the listed keys.
      
        For example,
            HashTable<someType> largeCache;
            wordHashSet preserve = ...;
      
            largeCache.retain(preserve);
      
          being roughly equivalent to the following two-stage process,
          but with reduced overhead and typing, and fewer potential mistakes.
      
            HashTable<someType> largeCache;
            wordHashSet preserve = ...;
      
            {
                wordHashSet cull(largeCache.toc()); // all keys
                cull.erase(preserve);               // except those to preserve
                largeCache.erase(cull);             //
            }
      
        The HashSet &= operator and retain() are functionally equivalent,
        but retain() also works with dissimilar value types.
      f73b5b62
  23. May 04, 2017
    • Mark OLESEN's avatar
      BUG: odd table size after shrink (issue #460) · 6747d14d
      Mark OLESEN authored
      - remove this unused method
      6747d14d
    • Mark OLESEN's avatar
      ENH: improve HashTable iterator access and management · 03d18072
      Mark OLESEN authored
      - provide key_iterator/const_key_iterator for all hashes,
        reuse directly for HashSet as iterator/const_iterator, respectively.
      
      - additional keys() method for HashTable that returns a wrapped to
        a pair of begin/end const_iterators with additional size/empty
        information that allows these to be used directly by anything else
        expecting things with begin/end/size. Unfortunately does not yet
        work with std::distance().
      
        Example,
           for (auto& k : labelHashTable.keys())
           {
              ...
           }
      03d18072
  24. May 02, 2017
  25. May 01, 2017
    • Mark OLESEN's avatar
      ENH: improve overall consistency of the HashTable and its iterators · c0a50dc6
      Mark OLESEN authored
      - previously had a mismash of const/non-const attributes on iterators
        that were confused with the attributes of the object being accessed.
      
      - use the iterator keys() and object() methods consistently for all
        internal access of the HashTable iterators. This makes the intention
        clearer, the code easier to maintain, and protects against any
        possible changes in the definition of the operators.
      
      - 'operator*': The standard form expected by STL libraries.
        However, for the std::map, this dereferences to a <key,value> pair,
        whereas OpenFOAM dereferences simply to <value>.
      
      - 'operator()': OpenFOAM treats this like the 'operator*'
      
      - adjusted the values of end() and cend() to reinterpret from nullObject
        instead of returning a static iteratorEnd() object.
        This means that C++ templates can now correctly deduce and match
        the return types from begin() and end() consistently.
        So that range-based now works.
      
        Eg,
            HashTable<label> table1 = ...;
            for (auto i : table1)
            {
                Info<< i << endl;
            }
      
        Since the 'operator*' returns hash table values, this prints all the
        values in the table.
      c0a50dc6
  26. Apr 30, 2017
    • Mark OLESEN's avatar
      ENH: HashTable improvements · 5d6bf3e4
      Mark OLESEN authored
      - optimize erasure using different HashTable based on its size.
        Eg, hashtable.erase(other);
      
        If 'other' is smaller than the hashtable, it is more efficient to
        use the keys from other to remove from the hashtable.
      
        Otherwise simply iterate over the hashtable and remove it if
        that key was found in other.
      5d6bf3e4
  27. Apr 29, 2017
    • Mark OLESEN's avatar
      ENH: support HashTable erasure via a FixedList · a2ddf7dd
      Mark OLESEN authored
      - propagate common erasure methods as HashSet::unset() method,
        for symmetry with HashSet::set()
      a2ddf7dd
    • Mark OLESEN's avatar
      STYLE: HashTable documentation · ded105c5
      Mark OLESEN authored
      - explicitly mention the value-initialized status for the operator().
        This means that the following code will properly use an initialized
        zero.
      
            HashTable<label> regionCount;
      
            if (...)
               regionCount("region1")++;
      
            ... and also this;
      
            if (regionCount("something") > 0)
            {
                ...
            }
      
        Note that the OpenFOAM HashTable uses operator[] to provide read and
        write access to *existing* entries and will provoke a FatalError if
        the entry does not exist.
      
        The operator() provides write access to *existing* entries or will
        create the new entry as required.
        The STL hashes use operator[] for this purpose.
      ded105c5
  28. Apr 11, 2017
  29. Aug 11, 2016
  30. Aug 08, 2016
  31. Aug 05, 2016
  32. Feb 28, 2016
  33. Jan 20, 2016
  34. Jan 10, 2016
  35. Nov 08, 2015
  36. Aug 14, 2011