All Projects → limen → fastrq

limen / fastrq

Licence: MIT license
Queue, Stack and Priority Queue built on Redis.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to fastrq

shoki
Purely functional data structures in Java
Stars: ✭ 30 (+100%)
Mutual labels:  stack, queue
C Macro Collections
Easy to use, header only, macro generated, generic and type-safe Data Structures in C
Stars: ✭ 192 (+1180%)
Mutual labels:  stack, queue
Algo Tree
Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
Stars: ✭ 166 (+1006.67%)
Mutual labels:  stack, queue
Redux Data Structures
Reducer factory functions for common data structures: counters, maps, lists (queues, stacks), sets, etc.
Stars: ✭ 157 (+946.67%)
Mutual labels:  stack, queue
ctl
My variant of the C Template Library
Stars: ✭ 105 (+600%)
Mutual labels:  stack, queue
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (+973.33%)
Mutual labels:  stack, queue
Interview Questions
List of all the Interview questions practiced from online resources and books
Stars: ✭ 187 (+1146.67%)
Mutual labels:  stack, queue
Cs2223
This a repository for WPI CS2223 Algorithms D Term 2018
Stars: ✭ 121 (+706.67%)
Mutual labels:  stack, queue
Data-Structure-Algorithm-Programs
This Repo consists of Data structures and Algorithms
Stars: ✭ 464 (+2993.33%)
Mutual labels:  stack, queue
data-structure-project
自己实现集合框架系列整理总结
Stars: ✭ 29 (+93.33%)
Mutual labels:  stack, queue
Data Structures
Common data structures and algorithms implemented in JavaScript
Stars: ✭ 139 (+826.67%)
Mutual labels:  stack, queue
quetie
🎀 Just the cutest and tiniest queue/deque implementation!
Stars: ✭ 111 (+640%)
Mutual labels:  stack, queue
Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (+733.33%)
Mutual labels:  stack, queue
Interviewbit
Collection of Abhishek Agrawal's gists solutions for problems on https://www.interviewbit.com
Stars: ✭ 166 (+1006.67%)
Mutual labels:  stack, queue
Data Structures With Go
Data Structures with Go Language
Stars: ✭ 121 (+706.67%)
Mutual labels:  stack, queue
Leetcode
High-quality LeetCode solutions
Stars: ✭ 178 (+1086.67%)
Mutual labels:  stack, queue
Buckets Swift
Swift Collection Data Structures Library
Stars: ✭ 106 (+606.67%)
Mutual labels:  stack, queue
Collections.pooled
Fast, low-allocation ports of List, Dictionary, HashSet, Stack, and Queue using ArrayPool and Span.
Stars: ✭ 115 (+666.67%)
Mutual labels:  stack, queue
Data Structures
A collection of powerful data structures
Stars: ✭ 2,534 (+16793.33%)
Mutual labels:  stack, queue
needle
📌📚 An extensive standalone data structure library for JavaScript.
Stars: ✭ 25 (+66.67%)
Mutual labels:  stack, queue

Fastrq - Queue, Stack and Priority Queue built on Redis

Build Status

Wiki

Fastrq for PHP

Features

  • Abstract Queue, Deque, Capped Queue/Deque, and Overflow-able Capped Queue/Deque
  • Abstract Stack, Capped Stack
  • Abstract Priority Queue, Capped Priority Queue and Overflow-able Capped Priority Queue
  • Push and Pop support batch operation
  • Using Lua scripts to save RTT (Round Trip Time)
  • Support getting indexes of members
  • Support pushing only if a member not already inside the queue
  • Support pushing only if the queue already exists/not already exist
  • All operations are atomic

Requirements

  • Redis >=3.0.2
  • Python 2.7 or >=3.4

Installation

via pip

pip install fastrq

or from source

python setup.py install

Usage

from fastrq.queue import Queue, CappedQueue
from fastrq.deque import Deque
from fastrq.stack import Stack
from fastrq.priorityqueue import PriorityQueue

# queue
q = Queue("fastrq_queue")
q.push(1)
q.push([2, 3])
q.push_ni(1) # got [3, False]. `ni` stands for `not inside`
q.push_ae(1) # got 4. `ae` stands for `already exists`
q.push_ne(1) # got False. `ne` stands for `not already exist`
q.ttl(10)   # set the lifetime in seconds
q.range(0, -1)  # got ['1', '2', '3']
q.range(0, 1)  # got ['1', '2']
q.indexof_one(1); # got 0
q.indexof_one(2); # got 1
q.indexof_one(4); # got None
q.indexof_many([1, 2, 4]); # got {1: 0, 2: 1, 4: None}
# push only if the member not inside the queue
q.push_ni(4) # got [4, True]
q.pop()
q.pop(2)
q.destruct() # destruct the queue
cq = CappedQueue("fastrq_capped_queue", 3)
cq.push(1)
cq.push(2)
cq.push([3, 4]) # got "err_qof"
cq.push(3)
cq.push(4) # got "err_qf"
of_cq = OfCappedQueue("fastrq_of_capped_queue", 3)
of_cq.push(1)
of_cq.push([2, 3, 4])  # "1" would be forced out


# deque
dq = Deque("fastrq_deque")
dq.push_front([1, 2])
dq.push_back([3, 4])
dq.pop_front()
dq.pop_back()
dq.push_front_ni(3)
dq.push_back_ni(5)

# priority queue
pq = PriorityQueue("fastrq_priority_queue")
pq.push({'alibaba': 1})
pq.push({'google': 0, 'microsoft': 2})
pq.indexof_one('google'); # got 0
pq.indexof_one('alibaba'); # got 1
pq.indexof_one('baidu'); # got None
pq.pop()
pq.pop(2)
pq.push_ni('ibm', 4)
pq.push_ni('amazon', 5)

# stack
s = Stack("fastrq_stack")
s.push([1,2,3])
s.indexof_one(1); # got 2
s.indexof_one(2); # got 1
s.indexof_one(3); # got 0
s.pop()
s.push_ni(4)

Data types

Queue

  • first in and first out
  • unlimited capacity
  • support batch push and batch pop

Deque

Derive from queue with more features

  • support push front and push back
  • support pop front and pop back

Capped Queue/Deque

Derive from queue/deque with more features

  • Have fixed capacity
  • Push to a full one would fail
  • Push to one whose positions are not enough would fail

Overflow-able Capped Queue/Deque

Derive from capped queue/deque with more features

  • The queue length would never exceed its capacity
  • Push to an end would force out from the other end if one is full

Stack

  • Last in and First out
  • Unlimited capacity
  • Support batch push and batch pop

Capped Stack

Derive from Stack with more features

  • Have fixed capacity
  • Push to a full capped stack would fail
  • Push to a capped stack whose positions are not enough would fail

Priority Queue

  • The lower the score, the higher the priority
  • Unlimited capacity
  • Support batch push and batch pop

Capped Priority Queue

Derive from Priority Queue with more features

  • Have fixed capacity
  • Push to a full one would fail
  • Push to a capped one whose positions are not enough would fail

Overflow-able Capped Priority Queue

Derive from Capped Priority Queue with more features

  • The queue length would never exceed its capacity
  • Push to would force out the lowest priority if queue is full
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].