Sentinels in collections, was RE: Primitive Queue<any T> considerations

Richard Warburton richard.warburton at gmail.com
Wed Nov 18 23:15:16 UTC 2015


Hi,

Many primitive collections use sentinels *without* requiring removal of
> those in the collection. This is done by storing a bit of side information.
> For example, for a set of int, GS Collections uses 0 and 1 as sentinels
> (meaning empty and removed, respectively). Every call to methods like
> get/contains/add/etc first checks to see if the value is a sentinel, and if
> so, queries/updates the side data. For a set, the side data is tiny and
> trivial: there is a single byte that encode if the set contains 0, 1, both
> or none.
>

This is entirely correct. Its not that there's a lack of ability to
implement what was being asked for, I was questioning what people's use
cases were around the feature. When I've done primitive collections I've
not added this feature. That's not because I didn't know how to, but
because it simply wasn't required for my use case. In that case why would I
add the complexity and overhead?

My perspective on software is that it should be written to solve problems
that actually exist, rather than problems which are hypothesized. Again - I
don't want to claim that the only use cases that matter are mine, but its
incredibly telling that there were 4 replies to that email, and only 1 of
them actually listed a use case. I'm still not 100% convinced by that but
thanks for providing it. (Of course you don't actually have to convince me
of anything - that's also fine ;) )

regards,

  Richard Warburton

  http://insightfullogic.com
  @RichardWarburto <http://twitter.com/richardwarburto>


More information about the valhalla-dev mailing list