1. 11 Nov, 2019 1 commit
  2. 31 Oct, 2019 1 commit
  3. 05 Nov, 2019 1 commit
  4. 06 May, 2019 1 commit
    • 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
  5. 06 Feb, 2019 1 commit
  6. 08 Jan, 2019 2 commits
    • 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
  7. 29 May, 2018 1 commit
  8. 17 May, 2018 1 commit
    • 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
  9. 14 Mar, 2018 1 commit
  10. 08 Feb, 2018 1 commit
  11. 25 Jan, 2018 1 commit
    • 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
  12. 23 Jan, 2018 1 commit
  13. 31 Oct, 2017 1 commit
    • 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
  14. 27 Oct, 2017 1 commit
    • 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
  15. 20 Sep, 2017 1 commit
    • 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
  16. 29 May, 2017 1 commit
  17. 26 May, 2017 1 commit
    • 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
  18. 17 May, 2017 1 commit
    • 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
  19. 15 May, 2017 1 commit
  20. 11 May, 2017 1 commit
    • 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
  21. 04 May, 2017 2 commits
    • 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
  22. 02 May, 2017 1 commit
  23. 01 May, 2017 1 commit
    • 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
  24. 30 Apr, 2017 1 commit
    • 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
  25. 29 Apr, 2017 2 commits
    • 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
  26. 11 Apr, 2017 1 commit
  27. 11 Aug, 2016 1 commit
  28. 08 Aug, 2016 1 commit
  29. 05 Aug, 2016 2 commits
  30. 28 Feb, 2016 1 commit
  31. 20 Jan, 2016 1 commit
  32. 10 Jan, 2016 1 commit
  33. 08 Nov, 2015 1 commit
  34. 14 Aug, 2011 1 commit
  35. 19 Jan, 2011 1 commit
  36. 14 Jan, 2011 1 commit