newSkipList is a function that creates an instance of a SkipList struct object and returns a pointer to it. This involves initializing the level of the SkipList to 1 and creating a new SkipListNode object as the head of the list. The head node is constructed with a level set to SKIPLIST_MAX_LEVEL, k
()
| 179 | // This involves initializing the level of the SkipList to 1 and creating a new SkipListNode object as the head of the list. |
| 180 | // The head node is constructed with a level set to SKIPLIST_MAX_LEVEL, key and value as empty string and value as nil respectively. |
| 181 | func newSkipList() *SkipList { |
| 182 | return &SkipList{ |
| 183 | level: 1, |
| 184 | head: newSkipListNode(SKIPLIST_MAX_LEVEL, 0, "", nil), |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | // newSkipListNode is a function that takes integer as level, score and a string as key along with a value of any type. |
| 189 | // It returns a pointer to a SkipListNode. This function is responsible for creating a new SkipListNode with provided level, score, |