chunky

package module
v0.0.0-...-bce9da5 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: MIT Imports: 0 Imported by: 0

README

CHUNKY

Build Status License Project status

Not the package you needed but the package you deserved. Chunk the slices up by creating an iterator specifically for each data types with ease. Because you are lazy maybe?

Installing
go get -u github.com/Anondo/chunky

Usage

Import The Package

import "github.com/Anondo/chunky"

Create An Iterator & Iterate Over The Chunks

data := []int{}

for i := 0; i < 10000; i++ {
  data = append(data, i)
}

itr := chunky.IntIterator{
  Chunkable:   data,
  ChunkLength: 450,
}

itr.ChunkUp()

log.Println("Chunks:")

for itr.Next() {
  log.Println(itr.CurrentBlock)
}

OR

Use the whole chunk


log.Println(itr.Chunk)

Using The Factory Function

data := []int{}

for i := 0; i < 10000; i++ {
	data = append(data, i)
}

itr := chunky.NewIntIterator(data, 450)

log.Println("Chunks:")

for itr.Next() {
	log.Println(itr.GetCurrentBlock().([]int)) // Need to type cast because GetCurrentBlock returns an empty interface
}

You need to type cast the chunks to use it, as the factory functions return an Iterator interface. So to play with the actual chunk:


log.Println(itr.(*chunky.IntIterator).Chunk)

Try out the iterators for other data types as well.

Contributing

See the contributions guide here.

License

Chunky is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolIterator

type BoolIterator struct {
	Chunkable    []bool
	ChunkLength  int
	Chunk        [][]bool
	CurrentBlock []bool
}

BoolIterator ...

func (*BoolIterator) ChunkUp

func (itr *BoolIterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*BoolIterator) GetCurrentBlock

func (itr *BoolIterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*BoolIterator) Next

func (itr *BoolIterator) Next() bool

Next pops the chunks sequentially

type Complex128Iterator

type Complex128Iterator struct {
	Chunkable    []complex128
	ChunkLength  int
	Chunk        [][]complex128
	CurrentBlock []complex128
}

Complex128Iterator ...

func (*Complex128Iterator) ChunkUp

func (itr *Complex128Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Complex128Iterator) GetCurrentBlock

func (itr *Complex128Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Complex128Iterator) Next

func (itr *Complex128Iterator) Next() bool

Next pops the chunks sequentially

type Complex64Iterator

type Complex64Iterator struct {
	Chunkable    []complex64
	ChunkLength  int
	Chunk        [][]complex64
	CurrentBlock []complex64
}

Complex64Iterator ...

func (*Complex64Iterator) ChunkUp

func (itr *Complex64Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Complex64Iterator) GetCurrentBlock

func (itr *Complex64Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Complex64Iterator) Next

func (itr *Complex64Iterator) Next() bool

Next pops the chunks sequentially

type Float32Iterator

type Float32Iterator struct {
	Chunkable    []float32
	ChunkLength  int
	Chunk        [][]float32
	CurrentBlock []float32
}

Float32Iterator ...

func (*Float32Iterator) ChunkUp

func (itr *Float32Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Float32Iterator) GetCurrentBlock

func (itr *Float32Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Float32Iterator) Next

func (itr *Float32Iterator) Next() bool

Next pops the chunks sequentially

type Float64Iterator

type Float64Iterator struct {
	Chunkable    []float64
	ChunkLength  int
	Chunk        [][]float64
	CurrentBlock []float64
}

Float64Iterator ...

func (*Float64Iterator) ChunkUp

func (itr *Float64Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Float64Iterator) GetCurrentBlock

func (itr *Float64Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Float64Iterator) Next

func (itr *Float64Iterator) Next() bool

Next pops the chunks sequentially

type Int16Iterator

type Int16Iterator struct {
	Chunkable    []int16
	ChunkLength  int
	Chunk        [][]int16
	CurrentBlock []int16
}

Int16Iterator ...

func (*Int16Iterator) ChunkUp

func (itr *Int16Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Int16Iterator) GetCurrentBlock

func (itr *Int16Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Int16Iterator) Next

func (itr *Int16Iterator) Next() bool

Next pops the chunks sequentially

type Int32Iterator

type Int32Iterator struct {
	Chunkable    []int32
	ChunkLength  int
	Chunk        [][]int32
	CurrentBlock []int32
}

Int32Iterator ...

func (*Int32Iterator) ChunkUp

func (itr *Int32Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Int32Iterator) GetCurrentBlock

func (itr *Int32Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Int32Iterator) Next

func (itr *Int32Iterator) Next() bool

Next pops the chunks sequentially

type Int64Iterator

type Int64Iterator struct {
	Chunkable    []int64
	ChunkLength  int
	Chunk        [][]int64
	CurrentBlock []int64
}

Int64Iterator ...

func (*Int64Iterator) ChunkUp

func (itr *Int64Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Int64Iterator) GetCurrentBlock

func (itr *Int64Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Int64Iterator) Next

func (itr *Int64Iterator) Next() bool

Next pops the chunks sequentially

type Int8Iterator

type Int8Iterator struct {
	Chunkable    []int8
	ChunkLength  int
	Chunk        [][]int8
	CurrentBlock []int8
}

Int8Iterator ...

func (*Int8Iterator) ChunkUp

func (itr *Int8Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Int8Iterator) GetCurrentBlock

func (itr *Int8Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Int8Iterator) Next

func (itr *Int8Iterator) Next() bool

Next pops the chunks sequentially

type IntIterator

type IntIterator struct {
	Chunkable    []int
	ChunkLength  int
	Chunk        [][]int
	CurrentBlock []int
}

IntIterator ...

func (*IntIterator) ChunkUp

func (itr *IntIterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*IntIterator) GetCurrentBlock

func (itr *IntIterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*IntIterator) Next

func (itr *IntIterator) Next() bool

Next pops the chunks sequentially

type Iterator

type Iterator interface {
	ChunkUp()
	Next() bool
	GetCurrentBlock() interface{}
}

Iterator ...

func NewBoolIterator

func NewBoolIterator(chunkable []bool, chunkLength int) Iterator

NewBoolIterator ...

func NewComplex128Iterator

func NewComplex128Iterator(chunkable []complex128, chunkLength int) Iterator

NewComplex128Iterator ...

func NewComplex64Iterator

func NewComplex64Iterator(chunkable []complex64, chunkLength int) Iterator

NewComplex64Iterator ...

func NewFloat32Iterator

func NewFloat32Iterator(chunkable []float32, chunkLength int) Iterator

NewFloat32Iterator ...

func NewFloat64Iterator

func NewFloat64Iterator(chunkable []float64, chunkLength int) Iterator

NewFloat64Iterator ...

func NewInt16Iterator

func NewInt16Iterator(chunkable []int16, chunkLength int) Iterator

NewInt16Iterator ...

func NewInt32Iterator

func NewInt32Iterator(chunkable []int32, chunkLength int) Iterator

NewInt32Iterator ...

func NewInt64Iterator

func NewInt64Iterator(chunkable []int64, chunkLength int) Iterator

NewInt64Iterator ...

func NewInt8Iterator

func NewInt8Iterator(chunkable []int8, chunkLength int) Iterator

NewInt8Iterator ...

func NewIntIterator

func NewIntIterator(chunkable []int, chunkLength int) Iterator

NewIntIterator ...

func NewStringIterator

func NewStringIterator(chunkable []string, chunkLength int) Iterator

NewStringIterator ...

func NewUint16Iterator

func NewUint16Iterator(chunkable []uint16, chunkLength int) Iterator

NewUint16Iterator ...

func NewUint32Iterator

func NewUint32Iterator(chunkable []uint32, chunkLength int) Iterator

NewUint32Iterator ...

func NewUint64Iterator

func NewUint64Iterator(chunkable []uint64, chunkLength int) Iterator

NewUint64Iterator ...

func NewUint8Iterator

func NewUint8Iterator(chunkable []uint8, chunkLength int) Iterator

NewUint8Iterator ...

func NewUintIterator

func NewUintIterator(chunkable []uint, chunkLength int) Iterator

NewUintIterator ...

func NewUintptrIterator

func NewUintptrIterator(chunkable []uintptr, chunkLength int) Iterator

NewUintptrIterator ...

type StringIterator

type StringIterator struct {
	Chunkable    []string
	ChunkLength  int
	Chunk        [][]string
	CurrentBlock []string
}

StringIterator ...

func (*StringIterator) ChunkUp

func (itr *StringIterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*StringIterator) GetCurrentBlock

func (itr *StringIterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*StringIterator) Next

func (itr *StringIterator) Next() bool

Next pops the chunks sequentially

type Uint16Iterator

type Uint16Iterator struct {
	Chunkable    []uint16
	ChunkLength  int
	Chunk        [][]uint16
	CurrentBlock []uint16
}

Uint16Iterator ...

func (*Uint16Iterator) ChunkUp

func (itr *Uint16Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Uint16Iterator) GetCurrentBlock

func (itr *Uint16Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Uint16Iterator) Next

func (itr *Uint16Iterator) Next() bool

Next pops the chunks sequentially

type Uint32Iterator

type Uint32Iterator struct {
	Chunkable    []uint32
	ChunkLength  int
	Chunk        [][]uint32
	CurrentBlock []uint32
}

Uint32Iterator ...

func (*Uint32Iterator) ChunkUp

func (itr *Uint32Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Uint32Iterator) GetCurrentBlock

func (itr *Uint32Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Uint32Iterator) Next

func (itr *Uint32Iterator) Next() bool

Next pops the chunks sequentially

type Uint64Iterator

type Uint64Iterator struct {
	Chunkable    []uint64
	ChunkLength  int
	Chunk        [][]uint64
	CurrentBlock []uint64
}

Uint64Iterator ...

func (*Uint64Iterator) ChunkUp

func (itr *Uint64Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Uint64Iterator) GetCurrentBlock

func (itr *Uint64Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Uint64Iterator) Next

func (itr *Uint64Iterator) Next() bool

Next pops the chunks sequentially

type Uint8Iterator

type Uint8Iterator struct {
	Chunkable    []uint8
	ChunkLength  int
	Chunk        [][]uint8
	CurrentBlock []uint8
}

Uint8Iterator ...

func (*Uint8Iterator) ChunkUp

func (itr *Uint8Iterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*Uint8Iterator) GetCurrentBlock

func (itr *Uint8Iterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*Uint8Iterator) Next

func (itr *Uint8Iterator) Next() bool

Next pops the chunks sequentially

type UintIterator

type UintIterator struct {
	Chunkable    []uint
	ChunkLength  int
	Chunk        [][]uint
	CurrentBlock []uint
}

UintIterator ...

func (*UintIterator) ChunkUp

func (itr *UintIterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*UintIterator) GetCurrentBlock

func (itr *UintIterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*UintIterator) Next

func (itr *UintIterator) Next() bool

Next pops the chunks sequentially

type UintptrIterator

type UintptrIterator struct {
	Chunkable    []uintptr
	ChunkLength  int
	Chunk        [][]uintptr
	CurrentBlock []uintptr
}

UintptrIterator ...

func (*UintptrIterator) ChunkUp

func (itr *UintptrIterator) ChunkUp()

ChunkUp divides the slices into chunks

func (*UintptrIterator) GetCurrentBlock

func (itr *UintptrIterator) GetCurrentBlock() interface{}

GetCurrentBlock returns the current block of chunk

func (*UintptrIterator) Next

func (itr *UintptrIterator) Next() bool

Next pops the chunks sequentially

Jump to

Keyboard shortcuts

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