github.com/djordje200179/extendedlibrary/datastructures@v1.7.1-0.20240227175559-d09520a92dd4/maps/linkmap/node.go (about) 1 package linkmap 2 3 // Node is a entry in the map. 4 // It is used to keep track of the order of the elements. 5 // It should not be created directly. 6 type Node[K, V any] struct { 7 key K 8 Value V // The Value of the entry stored in the node. 9 10 prev, next *Node[K, V] 11 } 12 13 // Key returns the key of the entry stored in the node. 14 func (node *Node[K, V]) Key() K { 15 return node.key 16 } 17 18 // Prev returns the previous node in the map. 19 func (node *Node[K, V]) Prev() *Node[K, V] { 20 return node.prev 21 } 22 23 // Next returns the next node in the map. 24 func (node *Node[K, V]) Next() *Node[K, V] { 25 return node.next 26 } 27 28 // Clone returns a copy of the node. 29 // The clone has the same key and value as the node. 30 // The clone does not have any links to other nodes. 31 func (node *Node[K, V]) Clone() *Node[K, V] { 32 return &Node[K, V]{ 33 key: node.key, 34 Value: node.Value, 35 } 36 }