summaryrefslogtreecommitdiff
path: root/libtnsl/box/list.tnsl
blob: 82f4f56ec34a900147df0744b68771d387e1e660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/#
  This Source Code Form is subject to the terms of the Mozilla Public
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
#/

;struct LNode (type T) {
	T data,
	~void next
}

/; method LNode
	/; get_next_type (type B) [LNode(B)]
		;return (self.next)[~LNode(B)]`
	;/

	/; get_next [LNode(T)]
		;return (self.next)[~LNode(T)]`
	;/
;/

;struct DLNode (type T) extends LNode(T) {
	super,
	~void prev
}

/; method DLNode
	/; get_prev_type (type B) [LNode(B)]
		;return (self.prev)[~LNode(B)]`
	;/

	/; get_prev [LNode(T)]
		;return (self.prev)[~LNode(T)]`
	;/
;/

;struct List (type T) {
	uint length,

	LNode(T)
		first,
		last
}

;struct DList (type T) {
	uint length,

	DLNode(T)
		first,
		last
}