Commit Graph

2 Commits

Author SHA1 Message Date
Bastien Montagne
fe9b21a44a Add GHash/GSet pop() feature.
Behavior is similar to python's set.pop(), it removes and returns a 'random' entry from the hash.

Notes:
* Popping will return items in same order as ghash/gset iterators (i.e. increasing
  order in internal buckets-based storage), unless ghash/gset is modified in between.
* We are keeping a track of the latest bucket we popped out (through a 'state' parameter),
  this allows for similar performances to iterators when iteratively popping a whole hash
  (without it, we are roughly O(n!), with it we are roughly O(n)...).

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D1808
2016-02-20 15:28:25 +01:00
Bastien Montagne
2941b4ad9b BLI GHash: add some basic gtests.
We could likely add much more, but those already covers basic behavior and should be able
to catch most errors when editing this code.

Also added some performances tests as well (timing ghash insert/lookup under heavy loads,
for different kinds of keys).
2015-03-19 19:50:51 +01:00