sybilStack: A Data Type Providing Stack (LIFO) And Queue (FIFO)...

Description Usage Arguments Details Value Author(s) Examples

Description

These functions implement simple stack or queue functionality.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  stinit(stname)
  stclear(stname)
  stpush(stname, value)
  stpop(stname)
  stunshift(stname, value)
  stshift(stname)
  stseek(stname)
  stfirst(stname)
  stlist(stname)
  stlength(stname)
  stexists(stname)

Arguments

stname

A single character string, giving the name of the stack or queue.

value

Value to add to the stack or queue.

Details

The funtion stinit creates an empty stack named stname.

The funtion stclear removes the stack named stname.

The funtion stpush appends element value at the end of the stack named stname.

The funtion stpop removes the last element of the stack named stname and returns it invisible.

The funtion stunshift appends element value at the beginning of the stack stname.

The funtion stshift removes the first element of the stack named stname and returns it invisible.

The funtion stseek returns the last element of the stack named stname but does not remove it.

The funtion stfirst returns the first element of the stack named stname but does not remove it.

The funtion stlist returns the stack named stname as list.

The funtion stlength returns the number of elements stored in the stack named stname.

The funtion stexists returns TRUE if a stack named stname exists, otherwise FALSE.

Value

The functions stpop and stshift return the last/first element of the stack invisibly. The functions stseek and stfirst just return the last/first element.

Author(s)

Gabriel Gelius-Dietrich <geliudie@uni-duesseldorf.de>

Maintainer: Mayo Roettger <mayo.roettger@hhu.de>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  ## initialize empty stack named test
  stinit("test")

  ## add a few elemets
  stpush("test", 9)
  stpush("test", 3)
  stpush("test", 7)

  ## get last element
  stpop("test")

  ## remove stack
  stclear("test")

Example output

Loading required package: Matrix
Loading required package: lattice

sybil documentation built on May 31, 2021, 5:08 p.m.