Handbook
Glossary
dlist
Factor handbook
»
The language
»
Collections
»
Double-linked lists
Next:
dlist? ( object -- ? )
Vocabulary
dlists
Definition
IN:
dlists
TUPLE:
dlist
{
front
maybe{
dlist-link
}
initial:
f
}
{
back
maybe{
dlist-link
}
initial:
f
}
;
Methods
USING:
dlists
prettyprint.custom
;
M:
dlist
>pprint-sequence
dlist>sequence
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
clear-deque
f
>>front
f
>>back
drop
;
USING:
deques
dlists
kernel
;
M:
dlist
clone
<dlist>
[
[
push-back
]
curry
dlist-each
]
keep
;
USING:
accessors
combinators
deques
dlists
kernel
;
M:
dlist
delete-node
[
{
{
[
2dup
front>>
eq?
]
[
nip
pop-front*
]
}
{
[
2dup
back>>
eq?
]
[
nip
pop-back*
]
}
[
drop
unlink-node
]
}
cond
]
[
drop
f
>>prev
f
>>next
drop
]
2bi
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
deque-empty?
front>>
not
;
inline
USING:
deques
dlists
kernel
;
M:
dlist
deque-member?
[
=
]
with
dlist-any?
;
USING:
accessors
containers
dlists
kernel
;
M:
dlist
empty?
front>>
not
;
inline
USING:
accessors
combinators.short-circuit
dlists
kernel
;
M:
dlist
equal?
over
dlist?
[
[
front>>
]
bi@
[
2dup
{
[
and
]
[
[
obj>>
]
same?
]
}
2&&
]
[
[
next>>
]
bi@
]
while
or
not
]
[
2drop
f
]
if
;
USING:
containers
dlists
;
M:
dlist
items
dlist>sequence
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
peek-back*
back>>
[
obj>>
t
]
[
f
f
]
if*
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
peek-front*
front>>
[
obj>>
t
]
[
f
f
]
if*
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
pop-back*
[
[
empty-deque
]
unless*
prev>>
f
over
set-next-when
]
change-back
normalize-front
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
pop-front*
[
[
empty-deque
]
unless*
next>>
f
over
set-prev-when
]
change-front
normalize-back
;
USING:
dlists
prettyprint.custom
;
M:
dlist
pprint*
pprint-object
;
USING:
dlists
kernel
prettyprint.custom
;
M:
dlist
pprint-delims
drop
\
DL{
\
}
;
USING:
dlists
kernel
prettyprint.custom
;
M:
dlist
pprint-narrow?
drop
f
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
push-back*
[
[
f
<dlist-node>
dup
dup
]
[
set-next-when
]
bi
]
change-back
set-front-to-back
;
USING:
accessors
deques
dlists
kernel
;
M:
dlist
push-front*
[
f
swap
<dlist-node>
dup
dup
set-next-prev
]
change-front
set-back-to-front
;