All Projects → princemaple → elixir-queue

princemaple / elixir-queue

Licence: MIT License
Queue data structure for Elixir-lang

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to elixir-queue

linked-blocking-multi-queue
A concurrent collection that extends the existing Java concurrent collection library, offering an optionally-bounded blocking "multi-queue" based on linked nodes.
Stars: ✭ 41 (+127.78%)
Mutual labels:  data-structure, queue
C Macro Collections
Easy to use, header only, macro generated, generic and type-safe Data Structures in C
Stars: ✭ 192 (+966.67%)
Mutual labels:  data-structure, queue
Leetcode
High-quality LeetCode solutions
Stars: ✭ 178 (+888.89%)
Mutual labels:  data-structure, queue
js-symbol-tree
Turn any collection of objects into its own efficient tree or linked list using Symbol
Stars: ✭ 86 (+377.78%)
Mutual labels:  data-structure, queue
Tesseract
A set of libraries for rapidly developing Pipeline driven micro/macroservices.
Stars: ✭ 20 (+11.11%)
Mutual labels:  queue
getui
Getui sdk package for laravel.
Stars: ✭ 19 (+5.56%)
Mutual labels:  queue
mobx-collection-store
Data collection store for MobX
Stars: ✭ 36 (+100%)
Mutual labels:  data-structure
clyngor
Handy python wrapper around Potassco's Clingo ASP solver.
Stars: ✭ 20 (+11.11%)
Mutual labels:  wrapper
Coursera-Stanford-Graph-Search-Shortest-Paths-and-Data-Structures
Notebook for quick search
Stars: ✭ 29 (+61.11%)
Mutual labels:  data-structure
ffmpeg-progressbar-cli
A colored progress bar for FFmpeg.
Stars: ✭ 140 (+677.78%)
Mutual labels:  wrapper
js-data-structures-and-algorithms
JavaScript implementations of common data structure and algorithm concepts.
Stars: ✭ 31 (+72.22%)
Mutual labels:  data-structure
python-launch-library
A simple wrapper for the Launch Library web API
Stars: ✭ 20 (+11.11%)
Mutual labels:  wrapper
laravel-mjml
Laravel MJML offers support for rendering MJML syntax into in-line HTML that can be sent within mails.
Stars: ✭ 26 (+44.44%)
Mutual labels:  wrapper
oxford dictionary
📙 A Ruby wrapper for the Oxford Dictionary API
Stars: ✭ 23 (+27.78%)
Mutual labels:  wrapper
pastebin-csharp
API client for Pastebin in C#
Stars: ✭ 25 (+38.89%)
Mutual labels:  wrapper
rgdax
Wrapper for Coinbase pro (erstwhile GDAX) Cryptocurrency exchange
Stars: ✭ 34 (+88.89%)
Mutual labels:  wrapper
rust-sidekiq
Rust Sidekiq Client
Stars: ✭ 24 (+33.33%)
Mutual labels:  queue
leetcode
✍️ 200+ LeetCode solutions in Java
Stars: ✭ 53 (+194.44%)
Mutual labels:  data-structure
hugo-wrapper
The universal way to include Hugo binary to your project.
Stars: ✭ 27 (+50%)
Mutual labels:  wrapper
JirAgileR
User-friendly 🔹JIRA API wrapper. Track projects & issues from within R
Stars: ✭ 22 (+22.22%)
Mutual labels:  wrapper

Qex

Elixir CI Module Version Hex Docs Total Download License Last Updated

A :queue wrapper with improvements in API and addition of Protocol implementations

Protocols

Inspect, Collectable and Enumerable are implemented, use Qex with IO.inspect and Enum functions!

Function signatures

Parameters are re-ordered to better suit Elixir's awesome |>

Installation

The package can be installed as:

  1. Add :qex to your list of dependencies in mix.exs:

    def deps do
      [
        {:qex, "~> 0.5"}
      ]
    end
  2. Run mix deps.get

How to use

Read the docs

Protocols

iex> inspect Qex.new
"#Qex<[]>"

iex> Enum.count Qex.new(1..5)
5

iex> Enum.empty? Qex.new
true

iex> Enum.map Qex.new([1, 2, 3]), &(&1 + 1)
[2, 3, 4]

iex> inspect Enum.into(1..5, %Qex{})
"#Qex<[1, 2, 3, 4, 5]>"

# Leverages :queue.member/2 under the hood for performance
iex> Enum.member? Qex.new(1..10_000), 9_999
true

Create a new queue from a range

iex> inspect Qex.new(1..3)
"#Qex<[1, 2, 3]>"

Create a new queue from a list

iex> inspect Qex.new([1, 2, 3])
"#Qex<[1, 2, 3]>"

Add an element to the back of the queue

iex> q = Qex.new([:mid])
iex> Enum.to_list Qex.push(q, :back)
[:mid, :back]

Add an element to the front of the queue

iex> q = Qex.new([:mid])
iex> Enum.to_list Qex.push_front(q, :front)
[:front, :mid]

Get and remove an element from the front of the queue

iex> q = Qex.new([:front, :mid])
iex> {{:value, item}, _q} = Qex.pop(q)
iex> item
:front

iex> q = Qex.new
iex> {empty, _q} = Qex.pop(q)
iex> empty
:empty

Get and remove an element from the back of the queue

iex> q = Qex.new([:mid, :back])
iex> {{:value, item}, _q} = Qex.pop_back(q)
iex> item
:back

iex> q = Qex.new
iex> {empty, _q} = Qex.pop_back(q)
iex> empty
:empty

Reverse a queue

iex> q = Qex.new(1..3)
iex> Enum.to_list q
[1, 2, 3]
iex> Enum.to_list Qex.reverse(q)
[3, 2, 1]

Split a queue into two, the front n items are put in the first queue

iex> q = Qex.new 1..5
iex> {q1, q2} = Qex.split(q, 3)
iex> Enum.to_list q1
[1, 2, 3]
iex> Enum.to_list q2
[4, 5]

Join two queues together

iex> q1 = Qex.new 1..3
iex> q2 = Qex.new 4..5
iex> Enum.to_list Qex.join(q1, q2)
[1, 2, 3, 4, 5]

Return the first item

iex> q1 = Qex.new 1..3
iex> Qex.first(q1)
{:value, 1}
iex> q2 = Qex.new []
iex> Qex.first(q2)
:empty

iex> q1 = Qex.new 1..3
iex> Qex.first!(q1)
1

Return the last item

iex> q1 = Qex.new 1..3
iex> Qex.last(q1)
{:value, 3}
iex> q2 = Qex.new []
iex> Qex.last(q2)
:empty

iex> q1 = Qex.new 1..3
iex> Qex.last!(q1)
3

Why not "Queue"?

The name is taken... Hex link

Copyright and License

Copyright (c) 2018 Po Chen

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].