File: more-containers.lisp

package info (click to toggle)
cl-containers 20170403-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,072 kB
  • ctags: 1,387
  • sloc: lisp: 8,341; makefile: 14
file content (33 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download | duplicates (4)
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
(in-package #:containers)

;;; persistent-sorted-list-container

(defclass* persistent-sorted-list-container (sorted-container-mixin
                                             list-container concrete-container)
  "A list container that keeps its items sorted as needed. This uses pushnew-ordered."
  ()
  (:export-p t))


(defmethod insert-list ((container persistent-sorted-list-container) (list t))
  (loop for item in list do
        (insert-item container item)))


(defmethod insert-item ((container persistent-sorted-list-container) (item t))
  (pushnew-ordered
   item (slot-value container 'contents) (sorter container)
   :test (test container) :key (key container))
  (values item))


(defmethod update-item ((container persistent-sorted-list-container) (item t))
  (delete-item container item)
  (insert-item container item))


(defmethod ensure-sorted ((container persistent-sorted-list-container))
  container)

(defmethod force-sort ((container persistent-sorted-list-container))
  container)