3 ms·
Obviously you can do public class Node<T>{ Node prev, next; //stuff comes here .... } Then extend and have the overall code that deals with modifying t
by xxs 6y ago
Obviously you can do
public class Node<T>{
Node prev, next;
//stuff comes here
....
}
Then extend and have the overall code that deals with modifying the datastructure, but it's overall ugly. Personally I have written enough datastructures where linking nodes is useful. For example: red/black tree + insert order 'next' makes for a decent implementation of a moving median.
Yet, that's not what almost any developer would do normally.
- KMag 6y agoBut isn't that just what you were suggesting in the GP post in order to get rid of a layer of indirection?
- xxs 6y agoPerhaps, most of the time I have not created a general use data structure - just highly specialized ones. Extending would allow no references/indirection but it's rather ugly and it has to provide another function to instantiate (I'd consider reflection, i.e. Class.newInstance() not to be a good way to handle the case).