Git Product home page Git Product logo

lua-denque's Introduction

lua-denque

test codecov

Double-ended queue module.

Installation

luarocks install denque

Create a denque object.

dq = denque.new()

returns a new denque object.

Returns

  • deq:denque: a denque object.

Example

local denque = require('deq')
local dq = denque.new()

n = #denque

get number of elements held in the denque object.

local denque = require('deq')
local dq = denque.new()
local len = #dq

Returns

  • n:integer: number of items held in the denque object.

elm = denque:unshift( data )

insert data at the head.

Parameters

  • data:any: a non-nil data.

Returns

  • elm:denque.element: inserted denque.element object.

elm = denque:head()

get the head element.

Returns

  • elm:denque.element: denque.element object.

elm = denque:push( data )

insert data at the tail.

Parameters

  • data:any: a non-nil data.

Returns

  • elm:denque.element: inserted denque.element object.

elm = denque:tail()

get the tail element.

Returns

  • elm:denque.element: denque.element object.

data = denque:shift()

remove the head element and return the data held by the head element.

Returns

  • data:any: a data.

data = denque:pop()

remove the tail element and return the data held by the tail element.

Returns

  • data:any: a data.

data = denque:remove( elm )

remove the specified element and return the data held by the specified element.

Parameters

  • elm:denque.element: denque.element object.

Returns

  • data: a data.

denque.element object

data = elm:data( [newdata] )

set a newdata if newdata argument passed, and return a data held in element.

Parameters

  • newdata:any: a non-nil data.

Returns

  • data: a data.

elm = elm:prev()

get an previous denque.element object.

Returns

  • elm:denque.element: previous denque.element object.

elm = elm:next()

get a next denque.element object.

Returns

  • elm:deq.element: next denque.element object.

data = elm:remove()

remove element from associated denque and return the data held by the element.

Returns

  • data:any: a data.

lua-denque's People

Contributors

mah0x211 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.