Slice reduces the set of matched elements to a subset specified by a range of indices. The start index is 0-based and indicates the index of the first element to select. The end index is 0-based and indicates the index at which the elements stop being selected (the end index is not selected). The i
(start, end int)
| 56 | // until the end are selected. This works both for a positive and negative start |
| 57 | // index. |
| 58 | func (s *Selection) Slice(start, end int) *Selection { |
| 59 | if start < 0 { |
| 60 | start += len(s.Nodes) |
| 61 | } |
| 62 | if end == ToEnd { |
| 63 | end = len(s.Nodes) |
| 64 | } else if end < 0 { |
| 65 | end += len(s.Nodes) |
| 66 | } |
| 67 | return pushStack(s, s.Nodes[start:end]) |
| 68 | } |
| 69 | |
| 70 | // Get retrieves the underlying node at the specified index. |
| 71 | // Get without parameter is not implemented, since the node array is available |