Mercurial > repos > rhope
comparison list.rhope @ 96:5a08705f7610
Semi-broken cleanup of Array implementation
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 02 Aug 2010 05:12:19 -0400 |
parents | e73a93fb5de1 |
children | fa437d23bb24 |
comparison
equal
deleted
inserted
replaced
95:f4fd8962c385 | 96:5a08705f7610 |
---|---|
11 | 11 |
12 Set@List Leaf[list,index,value:out,invalid index] | 12 Set@List Leaf[list,index,value:out,invalid index] |
13 { | 13 { |
14 If[[index] < [0]] | 14 If[[index] < [0]] |
15 { | 15 { |
16 rev index <- [[[list]Buffer >>]Length >>]+[index] | 16 rev index <- [[[list]Buffer >>]Length]+[index] |
17 invalid index <- If[[rev index] < [0]] {} | 17 invalid index <- If[[rev index] < [0]] {} |
18 { | 18 { |
19 out,invalid index <- [list]Set[rev index, value] | 19 out,invalid index <- [list]Set[rev index, value] |
20 } | 20 } |
21 | 21 |
22 }{ | 22 }{ |
23 len <- [[list]Buffer >>]Length >> | 23 len <- [[list]Buffer >>]Length |
24 If[[index] > [len]] | 24 If[[index] > [len]] |
25 { | 25 { |
26 makeleft <- Yes | 26 makeleft <- Yes |
27 }{ | 27 }{ |
28 If[[[index] > [7]] And [[index] >= [len]]] | 28 If[[[index] > [7]] And [[index] >= [len]]] |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 _Right Set@List Leaf[list,index,val:out,didn't set] | 49 _Right Set@List Leaf[list,index,val:out,didn't set] |
50 { | 50 { |
51 len <- [[list]Buffer >>]Length >> | 51 len <- [[list]Buffer >>]Length |
52 do it <- If[[index] < [len]] {} | 52 do it <- If[[index] < [len]] {} |
53 { | 53 { |
54 ,didn't set <- If[[index]=[len]] | 54 ,didn't set <- If[[index]=[len]] |
55 { | 55 { |
56 didn't set,do it <- If[[index]>[7]] | 56 didn't set,do it <- If[[index]>[7]] |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 Length@List Leaf[list:out] | 65 Length@List Leaf[list:out] |
66 { | 66 { |
67 out <- [[list]Buffer >>]Length >> | 67 out <- [[list]Buffer >>]Length |
68 } | 68 } |
69 | 69 |
70 Last@List Leaf[list:out,none] | 70 Last@List Leaf[list:out,none] |
71 { | 71 { |
72 len <- [[list]Buffer >>]Length >> | 72 len <- [[list]Buffer >>]Length |
73 ,none <-If[len] | 73 ,none <-If[len] |
74 { | 74 { |
75 out <- [len]-[1] | 75 out <- [len]-[1] |
76 } | 76 } |
77 } | 77 } |
156 }{ | 156 }{ |
157 | 157 |
158 If[[index]<[[list]Right Offset >>]] | 158 If[[index]<[[list]Right Offset >>]] |
159 { | 159 { |
160 off index <- [index]-[[list]Offset >>] | 160 off index <- [index]-[[list]Offset >>] |
161 bsize <- [[list]Buffer >>]Length >> | 161 bsize <- [[list]Buffer >>]Length |
162 If[[off index]>[bsize]] | 162 If[[off index]>[bsize]] |
163 { | 163 { |
164 If[[[list]Right >>]Length] | 164 If[[[list]Right >>]Length] |
165 { | 165 { |
166 my end <- [[list]Offset >>]+[[[list]Buffer >>]Length] | 166 my end <- [[list]Offset >>]+[[[list]Buffer >>]Length] |
230 | 230 |
231 Last@List[list:out,none] | 231 Last@List[list:out,none] |
232 { | 232 { |
233 [[list]Right >>]Last | 233 [[list]Right >>]Last |
234 { out <- [~]+[[list]Right Offset >>] } | 234 { out <- [~]+[[list]Right Offset >>] } |
235 { out <- [[[[list]Buffer >>]Length >>]-[1]]+[[list]Offset >>] } | 235 { out <- [[[[list]Buffer >>]Length]-[1]]+[[list]Offset >>] } |
236 } | 236 } |
237 | 237 |
238 Append@List[list,val:out] | 238 Append@List[list,val:out] |
239 { | 239 { |
240 [list]Last | 240 [list]Last |
261 { next <- Offset >>[list] } | 261 { next <- Offset >>[list] } |
262 }{ | 262 }{ |
263 If[[index] < [[list]Right Offset >>]] | 263 If[[index] < [[list]Right Offset >>]] |
264 { | 264 { |
265 pos next <- [index]+[1] | 265 pos next <- [index]+[1] |
266 If[[pos next] < [[[[list]Buffer >>]Length >>]+[[list]Offset >>]]] | 266 If[[pos next] < [[[[list]Buffer >>]Length]+[[list]Offset >>]]] |
267 { | 267 { |
268 next <- Val[pos next] | 268 next <- Val[pos next] |
269 }{ | 269 }{ |
270 ,none <- [[list]Right >>]First | 270 ,none <- [[list]Right >>]First |
271 { next <- [~]+[[list]Right Offset >>] } | 271 { next <- [~]+[[list]Right Offset >>] } |