<div dir="ltr"><div>>
It doesn't seem like the members of an EnumSet
would be iterated frequently...</div><div><br></div><div>We use EnumSet and EnumMap extensively, frequently iterating over them (the enum's natural order being critical).<br></div><div><br></div><div>>
...usually
treated as a bag of named booleans used as a set of boolean
options. <br></div><div><br></div><div>So for us it's... "ordered bag of named booleans with cheap lookup".<br></div><div></div><div><br></div><div>But I agree our usage probably wouldn't benefit from sequenced/navigable functionality much (if at all).</div><div><br></div><div>--</div><div>Aaron Scott-Boddendijk<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 24, 2023 at 5:51 AM Stuart Marks <<a href="mailto:stuart.marks@oracle.com">stuart.marks@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>The idea of EnumSet implementing SortedSet or NavigableSet has
been around for a long time; see</p>
<p> <a href="https://bugs.openjdk.org/browse/JDK-6278287" target="_blank">https://bugs.openjdk.org/browse/JDK-6278287</a></p>
<p>But yes, EnumSet could also implement SequencedSet. Similarly,
EnumMap could implement SequencedMap, SortedMap, or NavigableMap.</p>
<p>Implementing NavigableSet/Map is somewhat onerous, given that
there's no AbstractNavigableSet/Map, and there are a lot of
methods and variations of views to be implemented.<br>
</p>
<p>I'm a bit skeptical about the usefulness of retrofitting
EnumSet/Map this way, though. My hunch is that EnumSet is usually
treated as a bag of named booleans used as a set of boolean
options. The EnumSet is passed around as an aggregate, with
individual enum instances tested at specific points in the code to
adjust the logic. It doesn't seem like the members of an EnumSet
would be iterated frequently, or that it would be useful to have
specific subsets of an EnumSet (which is what NavigableSet would
provide). Maybe similar analysis applies to EnumMap. <br>
</p>
<p>I could be convinced otherwise with use cases, though.<br>
</p>
<p>s'marks</p>
<p><br>
</p>
<div>On 5/23/23 2:57 AM, Tagir Valeev wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">Hello!
<div dir="auto"><br>
</div>
<div dir="auto">Looks like this was overlooked. On the other
hand, it could even implement SortedSet or Navigable set, as
it's essentially not just ordered but sorted, according to the
enum natural order. Same for EnumMap.</div>
<div dir="auto"><br>
</div>
<div dir="auto">With best regards,</div>
<div dir="auto">Tagir Valeev </div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, May 23, 2023, 11:46
Andrey Turbanov <<a href="mailto:turbanoff@gmail.com" target="_blank">turbanoff@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello.<br>
I've noticed that EnumSet unfortunately doesn't implement the
newly<br>
introduced interface SequencedSet.<br>
From the first look it fits into it.<br>
Is there a reason for that? Sorry if it was already discussed.<br>
<br>
Andrey Turbanov<br>
</blockquote>
</div>
</blockquote>
</div>
</blockquote></div>