(start, end int)
| 734 | } |
| 735 | |
| 736 | func (sl *SkipList) sanitizeIndexes(start, end int) (newStart, newEnd int) { |
| 737 | if start < 0 { |
| 738 | start = int(sl.length) + start + 1 |
| 739 | } |
| 740 | if end < 0 { |
| 741 | end = int(sl.length) + end + 1 |
| 742 | } |
| 743 | if start <= 0 { |
| 744 | start = 1 |
| 745 | } |
| 746 | if end <= 0 { |
| 747 | end = 1 |
| 748 | } |
| 749 | |
| 750 | return start, end |
| 751 | } |
| 752 | |
| 753 | // GetByRank returns the node at given rank. |
| 754 | // Note that the rank is 1-based integer. Rank 1 means the first node; Rank -1 means the last node. |