comparison pkg/mesh/node.go @ 4828:39ee00d06309

Merged remove-octree-debris branch back into default.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 05 Nov 2019 14:31:22 +0100
parents f4abfd0ee8ad
children
comparison
equal deleted inserted replaced
4825:5eb05714353a 4828:39ee00d06309
1 // Copyright (C) 2018 Michael Fogleman
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20 package mesh
21
22 type node struct {
23 i int32
24 t int32
25 prev *node
26 next *node
27 }
28
29 func newNode(nodes []node, i int32, prev *node) *node {
30 n := &nodes[i]
31 n.i = i
32 if prev == nil {
33 n.prev = n
34 n.next = n
35 } else {
36 n.next = prev.next
37 n.prev = prev
38 prev.next.prev = n
39 prev.next = n
40 }
41 return n
42 }
43
44 func (n *node) remove() *node {
45 n.prev.next = n.next
46 n.next.prev = n.prev
47 n.i = -1
48 return n.prev
49 }