Commit Graph

6 Commits

Author SHA1 Message Date
Mark Olesen
bac943e6fc ENH: new bitSet class and improved PackedList class (closes #751)
- The bitSet class replaces the old PackedBoolList class.
  The redesign provides better block-wise access and reduced method
  calls. This helps both in cases where the bitSet may be relatively
  sparse, and in cases where advantage of contiguous operations can be
  made. This makes it easier to work with a bitSet as top-level object.

  In addition to the previously available count() method to determine
  if a bitSet is being used, now have simpler queries:

    - all()  - true if all bits in the addressable range are empty
    - any()  - true if any bits are set at all.
    - none() - true if no bits are set.

  These are faster than count() and allow early termination.

  The new test() method tests the value of a single bit position and
  returns a bool without any ambiguity caused by the return type
  (like the get() method), nor the const/non-const access (like
  operator[] has). The name corresponds to what std::bitset uses.

  The new find_first(), find_last(), find_next() methods provide a faster
  means of searching for bits that are set.

  This can be especially useful when using a bitSet to control an
  conditional:

  OLD (with macro):

      forAll(selected, celli)
      {
          if (selected[celli])
          {
              sumVol += mesh_.cellVolumes()[celli];
          }
      }

  NEW (with const_iterator):

      for (const label celli : selected)
      {
          sumVol += mesh_.cellVolumes()[celli];
      }

      or manually

      for
      (
          label celli = selected.find_first();
          celli != -1;
          celli = selected.find_next()
      )
      {
          sumVol += mesh_.cellVolumes()[celli];
      }

- When marking up contiguous parts of a bitset, an interval can be
  represented more efficiently as a labelRange of start/size.
  For example,

  OLD:

      if (isA<processorPolyPatch>(pp))
      {
          forAll(pp, i)
          {
              ignoreFaces.set(i);
          }
      }

  NEW:

      if (isA<processorPolyPatch>(pp))
      {
          ignoreFaces.set(pp.range());
      }
2018-03-07 11:21:48 +01:00
Mark Olesen
6a541ccc92 COMP: avoid attempted auto-vivify with PackedBoolList []
- also ensure fewer side-effects from inplaceReorder

- provide ListOps::reorder especially for PackedList and PackedBoolList
  since they behave differently from regular lists.
2018-03-15 15:20:00 +01:00
Mark Olesen
3d3c14cbff ENH: add inplaceUniqueSort function
- determines a unique sort order (as per uniqueOrder) and uses that to
  reorder the list and possibly truncate it.
2017-03-08 11:10:16 +01:00
Mark Olesen
b7dc6d0441 ENH: add subsetList/inplaceSubsetList functions with unary predicate
- these are suitable for use with lambda functions.

- Deprecate the unused 3-parameter version of subset/inplaceSubset.

- Deprecate initList and initListList in favour of initializer_list

STYLE: adjust some comments, remove dead code in regionSizeDistribution.C
2017-03-07 17:00:30 +01:00
mattijs
97910c4d4a COMP: Test apps: make compile 2013-01-17 11:06:38 +00:00
laurence
e3ae44f31f ENH: ListOps: Add reverse and rotate functions
reverseList
inplaceReverseList
rotateList
inplaceRotateList

Remove reverse function from UList and call the ListOps from the other
reverse function.
2012-12-11 16:21:07 +00:00