Commit Graph

14 Commits

Author SHA1 Message Date
Mark Olesen
063d8edea1 PackedBoolList specializaton for operator=
- now that I re-examined the code, the note in commit 51fd6327a6
  can be mostly ignored

  PackedList isMaster(nPoints, 1u);
  is not really inefficient at all, since the '1u' is packed into
  32/64-bits before the subsequent assignment and doesn't involve
  shifts/masking for each index

  The same misinformation applies to the PackedList(size, 0u) form.
  It isn't much slower at all.

  Nonetheless, add bool specialization so that it is a simple assign.
2009-12-03 16:33:58 +01:00
Mark Olesen
58b7e64185 Use argList::addOption, argList::addBoolOption (almost) everywhere
- ensure that the standard options (eg, from timeSelector) also have
  some usage information
2009-12-03 13:32:12 +01:00
Mark Olesen
ceaaabab56 bugfix PackedList for non-optimized compilation
- use shift-right instead of shift-left formulation to avoid wrong behaviour
  with non-optimized compilation when the packed items fit exactly in the
  available number of bits.
2009-07-23 22:46:52 +02:00
Mark Olesen
6c9f2520e1 added another PackedListTest 2009-07-23 15:36:46 +02:00
Mark Olesen
106d417de0 StaticAssert added
- catch people using silly template sizes for FixedList, PackedList
2009-02-27 16:41:51 +01:00
Mark Olesen
dbc9b7427a PackedList iterator bugfix
- compare iteratorBase == iteratorBase by value, not position
  thus this works
      list[a] == list[b] ...

- compare iterator == iteratorBase and const_iterator == iteratorBase
  by position, not value. The inheritance rules means that this works:
      iter == list.end() ...
  this will compare positions:
      iter == list[5];
  Of course, this will still compare values:
      *iter == list[5];
2009-02-27 13:43:43 +01:00
Mark Olesen
69918f23c5 consistency update
- OSspecific: chmod() -> chMod(), even although it's not used anywhere

- ListOps get subset() and inplaceSubset() templated on BoolListType

- added UList<bool>::operator[](..) const specialization.
  Returns false (actually pTraits<bool>::zero) for out-of-range elements.
  This lets us use List<bool> with lazy evaluation and no noticeable
  change in performance.

- use rcIndex() and fcIndex() wherever possible.
  Could check if branching or modulus is faster for fcIndex().

- UList and FixedList get 'const T* cdata() const' and 'T* data()' members.
  Similar to the STL front() and std::string::data() methods, they return a
  pointer to the first element without needing to write '&myList[0]', recast
  begin() or violate const-ness.
2009-02-06 20:43:09 +01:00
Mark Olesen
1f6733d91d PackedList - activated lazy evaluation
- moving back to original flat addressing in iterators means there is no
  performance issue with using lazy evaluation
- set() method now has ~0 for a default value.
  We can thus simply write 'set(i) to trun on all of the bits.
  This means we can use it just like labelHashSet::set(i)
- added flip() method for inverting bits. I don't know where we might need
  it, but the STL has it so we might as well too.
2009-01-30 00:07:53 +01:00
Mark Olesen
4e56643efe PackedList improvements
- dropped auto-vivification for now (performance issue), but reworked to
  allow easy reinstatement
- derived both iterator and const_iterator from iteratorBase and use
  iteratorBase as our proxy for non-const access to the list elements.
  This allows properly chaining assignments:
     list[1] = list[2];
     list[1] = list[2] = 10;
- assigning iterators from iteratorBase or other iterators works:
     iterator iter = list[20];
- made template parameter nBits=1 the default
2009-01-29 14:03:53 +01:00
Mark Olesen
7c739978b1 PackedList gets count() and trim() methods
- the bit counting is relatively fast:
  under 0.2 seconds for 1M bits counted 1000 times

- trim()'ing the final zero elements tested for a few cases,
  but might need more attention
2009-01-28 16:32:47 +01:00
Mark Olesen
84ec272d23 PackedList changes
- added Mattijs' speed tests
- optimized resize() and assignment operators to avoid set() method
- add const_iterator and re-did the proxy handling.

Reading/writing by looping across iterators is still somewhat slow, but
might be acceptable.
2009-01-26 00:33:28 +01:00
Mark Olesen
cc4cd0a171 PackedList: encapsulate calculations in an iterator
- eliminated previous PackedBitRef class, the iterator does all of that and
  can also be used to (forward) traverse the list
- no const_iterator yet

- Note that PackedList is also a bit like DynamicList in terms of storage
  management and the append() method. Since the underlying storage in
  integer, any auto-vivified elements will also flood-fill the gaps with
  zero.
2009-01-23 01:40:55 +01:00
Mark Olesen
173607fd2d PackedList gets functionality akin to DynamicList 2009-01-22 16:24:05 +01:00
Mark Olesen
6d57bb4e7b added PackedBoolList typedef (used everywhere) and improved PackedList
- new members:  capacity(), two-argument resize()/setSize(), const storage()
- new static members: max_value(), packing(), etc.
2009-01-21 11:30:10 +01:00