Stands for first in first out. An eieio abstract class class to provide FIFO methods to slots.
- Emacs 24
A demo class:
(require 'fifo-class)
;; Require this package
(defclass testclass (fifo-class)
((testlist
:initform nil)))
;; A testclass have only one slot
(defvar my-object (make-instance 'testclass))
;; Make an instance of testclass and store in my-object
To push value
into slot
quene of object
.
(fifo-class-push my-object 'testlist 0)
;; testlist = '(0)
(fifo-class-push my-object 'testlist 1)
;; testlist = '(0 1)
(fifo-class-push my-object 'testlist 2)
;; testlist = '(0 1 2)
(fifo-class-push my-object 'testlist 3)
;; testlist = '(0 1 2 3)
Get the fisrt element in slot without changing the slot.
(fifo-class-first my-object 'testlist)
;; ==> 0
;; testlist = '(0 1 2 3)
(fifo-class-first my-object 'testlist)
;; ==> 0
;; testlist = '(0 1 2 3)
Remove the first element in slot
and return that item.
(setq a (fifo-class-pop my-object 'testlist))
;; a = 0
;; testlist = '(1 2 3)
(setq b (fifo-class-pop my-object 'testlist))
;; b = 1
;; testlist = '(2 3)
(setq c (fifo-class-pop my-object 'testlist))
;; c = 2
;; testlist = '(3)
(setq d (fifo-class-pop my-object 'testlist))
;; d = 3
;; testlist = nil
(setq e (fifo-class-pop my-object 'testlist))
;; d = nil
;; testlist = nil
If you find any bugs or have any suggestions, you can make a pull request or send me an email.