How to create a get Method with nodes off a generic type in java

后端 未结 3 1861
[愿得一人]
[愿得一人] 2021-01-26 03:39

I am implementing a cyclic DoublyLinkedList data structure. Like a singly linked list, nodes in a doubly linked list have a reference to the next node, but unlike a singly linke

3条回答
  •  有刺的猬
    2021-01-26 04:19

    You can also use a hash map, and you will get the data on constant time

    public T get(int position){
        Node node = map.get(position);
        T dat = node.getData();
        return dat;
    }
    

提交回复
热议问题