Latest0.2.0
Homepagehttps://github.com/to4iki/Queue
LicenseMIT
Platformsios 8.0, osx 10.9, requires ARC
Authors

Build Status
Version
MIT License
Platform

First-In-First-Out (FIFO) Simple Queue(immutable|mutable)

Description

Queue objects implement data structures that allow to
insert and retrieve elements in a first-in-first-out (FIFO) manner.

Usage

ImmutableQueue

let queue = ImmutableQueue<Int>()

enqueue

let q1 = queue.enqueue(1) // ImmutableQueue(1)
let q123 = q1.enqueue(2,3) // ImmutableQueue(1,2,3)
let q12345 = q123.enqueue([4,5]) // ImmutableQueue(1,2,3,4,5)

dequeue

let q123 = queue.enqueue(1,2,3)
let (q, qs) = q123.dequeue()
q // 1
qs // [2,3]

MutableQueue

var queue = MutableQueue<Int>()

enqueue(+=)

queue.enqueue(0)
queue.enqueue(1,2)
queue += 3
queue.count // 4

enqueue(++=)

queue.enqueue([0,1])
queue ++= [2,3]
queue.count // 4

dequeue

queue ++= [1,2,3]
let res = queue.dequeue()
res.head // 1
res.tail // [2.3]

clear

queue ++= [1,2,3]
queue.clear()
queue.count // 0

Methods

immutable.ImmutableQueue

  • Instance Methods
    • enqueue(elems: T...) -> ImmutableQueue
    • enqueue(elems: [T]) -> ImmutableQueue
    • dequeue() -> (head: T, tail: [T])
    • dequeueOption() -> (head: T, tail: [T])?
    • front() -> T?
    • tail() -> ImmutableQueue

mutable.MutableQueue

  • Instance Methods
    • enqueue(elems: T...)
    • enqueue(elems: [T])
    • dequeue() -> (head: T, tail: [T])
    • dequeueOption() -> (head: T, tail: [T])?
    • dequeueFirst(predicate: T -> Bool) -> T?
    • dequeueAll(predicate: T -> Bool) -> [T]
    • clear()
    • front() -> T?
    • tail() -> MutableQueue

Installation

Licence

MIT

Author

to4iki

Latest podspec

{
    "name": "Queue",
    "version": "0.2.0",
    "license": "MIT",
    "summary": "First-In-First-Out (FIFO) Simple Queue(immutable|mutable)",
    "homepage": "https://github.com/to4iki/Queue",
    "social_media_url": "http://twitter.com/to4iki",
    "authors": {
        "tsk takezawa": "[email protected]"
    },
    "source": {
        "git": "https://github.com/to4iki/Queue.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9"
    },
    "source_files": "Queue/**/*.swift",
    "requires_arc": "true"
}

Pin It on Pinterest

Share This