states

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2015 License: MIT Imports: 0 Imported by: 0

README

states

Package states implements state list, stack, queue based on a uint64, built for reduce allocations.

Stack

import "github.com/cosiner/gohper/states"

const (
    STATE1 uint = iota + 1
    STATE2
    STATE3
    STATE4
)

func main() {
    stack := states.NewStack(states.UnitSize(STATE4))

    stack.
        Push(STATE1).
        Push(STATE2).
        Push(STATE3).
        Push(STATE4).
        IsFull() // false

    stack.Pop() // STATE4
    stack.Pop() // STATE3
    stack.Pop() // STATE2
    stack.Pop() // STATE1
    stack.IsEmpty() // true
}

Others:

  • List
    • PushBack
    • PushFront
    • PopBack
    • PopFront
  • Queue
    • Push
    • Pop

Documentation

Overview

Package states implements state list, stack, queue based on a uint64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnitSize

func UnitSize(count uint) uint

Types

type List

type List struct {
	// contains filtered or unexported fields
}

func NewList

func NewList(unitsize uint) List

func (*List) IsEmpty

func (l *List) IsEmpty() bool

func (*List) IsFull

func (l *List) IsFull() bool

func (*List) MaxSize

func (l *List) MaxSize() uint

func (*List) PopBack

func (l *List) PopBack() uint

func (*List) PopFront

func (l *List) PopFront() uint

func (*List) PushBack

func (l *List) PushBack(state uint) *List

func (*List) PushFront

func (l *List) PushFront(state uint) *List

func (*List) Size

func (l *List) Size() uint

func (*List) UnitSize

func (l *List) UnitSize() uint

type Queue

type Queue struct {
	List
}

func NewQueue

func NewQueue(unitsize uint) Queue

func (*Queue) Pop

func (q *Queue) Pop() uint

func (*Queue) Push

func (q *Queue) Push(state uint) *Queue

type Stack

type Stack struct {
	List
}

func NewStack

func NewStack(unitsize uint) Stack

func (*Stack) Pop

func (s *Stack) Pop() uint

func (*Stack) Push

func (s *Stack) Push(state uint) *Stack

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL