1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel assocs deques ;
6 TUPLE: search-deque assoc deque ;
8 C: <search-deque> search-deque
10 M: search-deque deque-empty? deque>> deque-empty? ;
12 M: search-deque peek-front deque>> peek-front ;
14 M: search-deque peek-back deque>> peek-back ;
16 M: search-deque push-front*
17 2dup assoc>> at* [ 2nip ] [
19 [ deque>> push-front* ] [ assoc>> ] 2bi
20 [ 2drop ] [ set-at ] 3bi
23 M: search-deque push-back*
24 2dup assoc>> at* [ 2nip ] [
26 [ deque>> push-back* ] [ assoc>> ] 2bi
27 [ 2drop ] [ set-at ] 3bi
30 M: search-deque pop-front*
31 [ [ deque>> peek-front ] [ assoc>> ] bi delete-at ]
32 [ deque>> pop-front* ]
35 M: search-deque pop-back*
36 [ [ deque>> peek-back ] [ assoc>> ] bi delete-at ]
40 M: search-deque delete-node
41 [ deque>> delete-node ]
42 [ [ node-value ] [ assoc>> ] bi* delete-at ] 2bi ;
44 M: search-deque clear-deque
45 [ deque>> clear-deque ] [ assoc>> clear-assoc ] bi ;
47 M: search-deque deque-member?
50 INSTANCE: search-deque deque