Handbook
Glossary
indexed-seq
Vocabulary
game
.
models
.
util
Class description
A sequence described by a sequence of unique elements and a sequence of indices. The sequence can only be appended to. An associative map is used as a reverse lookup table when appending.
Definition
IN:
game.models.util
TUPLE:
indexed-seq
dseq iseq rassoc
;
Methods
USING:
accessors
game.models.util
sequences
;
M:
indexed-seq
length
iseq>>
length
;
inline
USING:
accessors
game.models.util
kernel
sequences
;
M:
indexed-seq
new-resizable
[
dseq>>
]
[
iseq>>
]
[
rassoc>>
]
tri
<indexed-seq>
dup
-rot
[
[
dseq>>
new-resizable
]
keep
dseq<<
]
[
[
iseq>>
new-resizable
]
keep
iseq<<
]
[
[
rassoc>>
clone
nip
]
keep
rassoc<<
]
2tri
;
USING:
accessors
game.models.util
kernel
sequences
;
M:
indexed-seq
nth
[
iseq>>
nth
]
keep
dseq>>
nth
;
inline
USING:
accessors
assocs
game.models.util
kernel
sequences
;
M::
indexed-seq
set-nth
( elt n seq -- )
seq
dseq>>
:>
dseq seq
iseq>>
:>
iseq seq
rassoc>>
:>
rassoc
seq
length
n
=
not
[
elt n seq
immutable
]
when
elt rassoc
at
[
iseq
push
]
[
dseq
length
[
elt rassoc
set-at
]
[
iseq
push
]
bi
elt dseq
push
]
if*
;
inline