Head returns the rest of the Stack from this Card up (excluding this Card). The slice is sorted vertically, starting with the top of the stack.
()
| 135 | |
| 136 | // Head returns the rest of the Stack from this Card up (excluding this Card). The slice is sorted vertically, starting with the top of the stack. |
| 137 | func (stack *Stack) Head() []*Card { |
| 138 | rest := []*Card{} |
| 139 | |
| 140 | above := stack.Above |
| 141 | tested := map[*Card]bool{} |
| 142 | for above != nil { |
| 143 | if _, exists := tested[above]; exists { |
| 144 | break |
| 145 | } |
| 146 | rest = append(rest, above) |
| 147 | tested[above] = true |
| 148 | above = above.Stack.Above |
| 149 | } |
| 150 | |
| 151 | sort.Slice(rest, func(i, j int) bool { return rest[i].Rect.Y < rest[j].Rect.Y }) |
| 152 | |
| 153 | return rest |
| 154 | } |
| 155 | |
| 156 | // Tail returns the rest of the Stack from this Card down (excluding this Card). The slice is sorted vertically, starting with the top of the stack. |
| 157 | func (stack *Stack) Tail() []*Card { |
no outgoing calls
no test coverage detected