-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Insertion Ordered Set implementing MutableSet API. #339
Comments
I think the title should be "implement insertion ordered set". Using a linked structure is the reason for the huge memory overhead of LinkedHashSet. Using a long[] to maintain the iteration order would be much more efficient. But maybe I'm missing a different reason why a linked structure might be useful? |
Makes sense. Updated. I'll leave implementation detail up to the developer who contributes. |
A removal from the middle of an IntList would turn Set.remove() into a
linear time operation, at least with the naive/obvious implementation. In
fact, any removal is complicated.
…On Sat, Dec 9, 2017 at 4:09 PM Stefan Oehme ***@***.***> wrote:
I think the title should be "implement insertion ordered set". Using a
linked structure is the reason for the huge memory overhead of
LinkedHashSet. Using an IntList to maintain the iteration order would be
much more efficient. But maybe I'm missing a different reason why a linked
structure might be useful?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#339 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAO6IsoTTxbm1ShQDdira-tkCoUVHsVAks5s-vcJgaJpZM4PKxdO>
.
|
I corrected my comment above - I meant keeping the links in a long[], storing the previous pointer in the lower half and the next pointer in the upper half of each long and indexing it with the same indexes as the main table. That gives you a compact link representation and constant time removals. |
Any updates in this? |
@arvidvillen what updates would you like? If you need this functionality, please feel free to contribute. |
@arvidvillen The most used collection for representing results coming from a database is a simple list. It's naturally ordered, random access and has a superior interface compared to a set. |
Thanks for super fast replies. But I understand not many people see it that way as there are very few collection libraries that support |
Today a LinkedHashSet can be used by wrapping a JDK LinkedHashSet with a SetAdapter as follows.
Sets.adapt(new LinkedHashSet());
This works fine for most cases but it would be nicer if we provided an Ordered Set implementation that returned more specific values out of certain methods.
The text was updated successfully, but these errors were encountered: