| 6. Sun Oct 06, 2019 - SortedIntList Design Decisions

Badlogic Games • View topic - SortedIntList Design Decisions

SortedIntList Design Decisions

Anything libgdx related goes here!

SortedIntList Design Decisions

Postby libbyjix » Sun Oct 06, 2019 9:36 am
Hey, I was looking for a linked list to use and saw that libGDX's already has one called "sortedintlist". I started using it but came across some, to my mind, oddities with the class:

1. the insert() function overwrites values like a set() or replace() type function when inserting into the middle of a list
- so I figured I would just manually insert new nodes as with traditional linked lists but
2. get() doesn't return the actual node but the value of the node
- so I have to manually loop through and find the node I want to insert after but
3. the class doesn't expose its node pool for use so the benefits of a node pool go to waste
- so I need to recreate a node pool external to the class and further
4. it uses integer indexes for indexing of nodes but those indexes aren't updated after a remove() with an iterator
- so I have to manually update all indexes after point of removal for them to remain valid

After these points of friction started piling up I came to the conclusion that I'm fundamentally misunderstanding how/why the class works the way it does. So before I run off and start heavily modifying things can someone respond with some insight here? thanks!
libbyjix
 
Posts: 18
Joined: Fri May 15, 2015 5:07 pm

Re: SortedIntList Design Decisions

Postby evilentity » Sun Oct 06, 2019 2:53 pm
Looks like more of a map then a list. Think of ints as keys not positions.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4867
Joined: Wed Aug 24, 2011 6:37 am

Re: SortedIntList Design Decisions

Postby libbyjix » Mon Oct 07, 2019 2:42 am
thanks for the reply. ok, I can see that, so like an ordered map? Wouldn't it help to alter the name or give a slightly longer description than "A sorted double linked list which uses ints for indexing." so people can quickly understand that this isn't a normal linked list data structure?

Out of curiosity, any idea of what coding situation would need a structure like this (e.g. is used by another class in libGDX) or is this just experimental?

Also, does libGDX already have an existing linked list implementation or is it fine to just use Java's standard library? I know libGDX created a lot of their own versions of data structures in order to avoid triggering the garbage collector.
libbyjix
 
Posts: 18
Joined: Fri May 15, 2015 5:07 pm



Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], libbyjix and 1 guest