list

package
v0.0.0-...-5012a73 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ElementPile

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

ElementPile is a hybrid container for a lazily and concurrently populated growing-only slice of items (of type `*list.Element`) which may be traversed in parallel to it's growth.

Usage for a pile `p`:

p := MakeElementPile(128, 32)

Have it grow concurrently using multiple:

var item *list.Element = something
p.Pile(item)

in as many go routines as You may seem fit.

In parallel, You may either traverse `p` in parallel right away:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

Here p.Iter() starts a new transversal with the first item (if any), and p.Next() keeps traverses the ElementPile.

or traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available:

r, p := <-p.Done(), nil

Hint: here we get the result in `r` and at the same time discard / deallocate / forget the pile `p` itself.

Note: The traversal is *not* intended to be concurrency safe! Thus: You may call `Pile` concurrently to Your traversal, but use of either `Done` or `Iter` and `Next` *must* be confined to a single go routine (thread).

func MakeElementPile

func MakeElementPile(size, buff int) *ElementPile

MakeElementPile returns a (pointer to a) fresh pile of items (of type `*list.Element`) with size as initial capacity and with buff as initial leeway, allowing as many Pile's to execute non-blocking before respective Done or Next's.

func (*ElementPile) Close

func (d *ElementPile) Close() (err error)

Close - call once when everything has been piled.

Close intentionally implements io.Closer

Note: After Close(), any Close(...) will panic and any Pile(...) will panic and any Done() or Next() will return immediately: no eventual blocking, that is.

func (*ElementPile) Done

func (d *ElementPile) Done() (done <-chan []*list.Element)

Done returns a channel which emits the result (as slice of Element) once the pile is closed.

Users of Done() *must not* iterate (via Iter() Next()...) before the done-channel is closed!

Done is a convenience - useful iff You do not like/need to start any traversal before the pile is fully populated. Once the pile is closed, Done() will signal in constant time.

Note: Upon signalling, the pile is reset to it's tip, so You may traverse it (via Next) right away. Usage for a pile `p`: Traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available

r, p := <-p.Done(), nil

while discaring the pile itself.

func (*ElementPile) Iter

func (d *ElementPile) Iter() (item *list.Element, ok bool)

Iter puts the pile iterator back to the beginning and returns the first `Next()`, iff any. Usage for a pile `p`:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

func (*ElementPile) Next

func (d *ElementPile) Next() (item *list.Element, ok bool)

Next returns the next item, or false iff the pile is exhausted.

Note: Iff the pile is not closed yet, Next may block, awaiting some Pile().

func (*ElementPile) Pile

func (d *ElementPile) Pile(item *list.Element)

Pile appends an `*list.Element` item to the ElementPile.

Note: Pile will block iff buff is exceeded and no Done() or Next()'s are used.

type ElementSPile

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

ElementSPile is a hybrid container for a lazily and concurrently populated growing-only slice of items (of type `[]*list.Element`) which may be traversed in parallel to it's growth.

Usage for a pile `p`:

p := MakeElementSPile(128, 32)

Have it grow concurrently using multiple:

var item []*list.Element = something
p.Pile(item)

in as many go routines as You may seem fit.

In parallel, You may either traverse `p` in parallel right away:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

Here p.Iter() starts a new transversal with the first item (if any), and p.Next() keeps traverses the ElementSPile.

or traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available:

r, p := <-p.Done(), nil

Hint: here we get the result in `r` and at the same time discard / deallocate / forget the pile `p` itself.

Note: The traversal is *not* intended to be concurrency safe! Thus: You may call `Pile` concurrently to Your traversal, but use of either `Done` or `Iter` and `Next` *must* be confined to a single go routine (thread).

func MakeElementSPile

func MakeElementSPile(size, buff int) *ElementSPile

MakeElementSPile returns a (pointer to a) fresh pile of items (of type `[]*list.Element`) with size as initial capacity and with buff as initial leeway, allowing as many Pile's to execute non-blocking before respective Done or Next's.

func (*ElementSPile) Close

func (d *ElementSPile) Close() (err error)

Close - call once when everything has been piled.

Close intentionally implements io.Closer

Note: After Close(), any Close(...) will panic and any Pile(...) will panic and any Done() or Next() will return immediately: no eventual blocking, that is.

func (*ElementSPile) Done

func (d *ElementSPile) Done() (done <-chan [][]*list.Element)

Done returns a channel which emits the result (as slice of ElementS) once the pile is closed.

Users of Done() *must not* iterate (via Iter() Next()...) before the done-channel is closed!

Done is a convenience - useful iff You do not like/need to start any traversal before the pile is fully populated. Once the pile is closed, Done() will signal in constant time.

Note: Upon signalling, the pile is reset to it's tip, so You may traverse it (via Next) right away. Usage for a pile `p`: Traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available

r, p := <-p.Done(), nil

while discaring the pile itself.

func (*ElementSPile) Iter

func (d *ElementSPile) Iter() (item []*list.Element, ok bool)

Iter puts the pile iterator back to the beginning and returns the first `Next()`, iff any. Usage for a pile `p`:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

func (*ElementSPile) Next

func (d *ElementSPile) Next() (item []*list.Element, ok bool)

Next returns the next item, or false iff the pile is exhausted.

Note: Iff the pile is not closed yet, Next may block, awaiting some Pile().

func (*ElementSPile) Pile

func (d *ElementSPile) Pile(item []*list.Element)

Pile appends an `[]*list.Element` item to the ElementSPile.

Note: Pile will block iff buff is exceeded and no Done() or Next()'s are used.

type ListSPile

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

ListSPile is a hybrid container for a lazily and concurrently populated growing-only slice of items (of type `[]*list.List`) which may be traversed in parallel to it's growth.

Usage for a pile `p`:

p := MakeListSPile(128, 32)

Have it grow concurrently using multiple:

var item []*list.List = something
p.Pile(item)

in as many go routines as You may seem fit.

In parallel, You may either traverse `p` in parallel right away:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

Here p.Iter() starts a new transversal with the first item (if any), and p.Next() keeps traverses the ListSPile.

or traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available:

r, p := <-p.Done(), nil

Hint: here we get the result in `r` and at the same time discard / deallocate / forget the pile `p` itself.

Note: The traversal is *not* intended to be concurrency safe! Thus: You may call `Pile` concurrently to Your traversal, but use of either `Done` or `Iter` and `Next` *must* be confined to a single go routine (thread).

func MakeListSPile

func MakeListSPile(size, buff int) *ListSPile

MakeListSPile returns a (pointer to a) fresh pile of items (of type `[]*list.List`) with size as initial capacity and with buff as initial leeway, allowing as many Pile's to execute non-blocking before respective Done or Next's.

func (*ListSPile) Close

func (d *ListSPile) Close() (err error)

Close - call once when everything has been piled.

Close intentionally implements io.Closer

Note: After Close(), any Close(...) will panic and any Pile(...) will panic and any Done() or Next() will return immediately: no eventual blocking, that is.

func (*ListSPile) Done

func (d *ListSPile) Done() (done <-chan [][]*list.List)

Done returns a channel which emits the result (as slice of ListS) once the pile is closed.

Users of Done() *must not* iterate (via Iter() Next()...) before the done-channel is closed!

Done is a convenience - useful iff You do not like/need to start any traversal before the pile is fully populated. Once the pile is closed, Done() will signal in constant time.

Note: Upon signalling, the pile is reset to it's tip, so You may traverse it (via Next) right away. Usage for a pile `p`: Traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available

r, p := <-p.Done(), nil

while discaring the pile itself.

func (*ListSPile) Iter

func (d *ListSPile) Iter() (item []*list.List, ok bool)

Iter puts the pile iterator back to the beginning and returns the first `Next()`, iff any. Usage for a pile `p`:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

func (*ListSPile) Next

func (d *ListSPile) Next() (item []*list.List, ok bool)

Next returns the next item, or false iff the pile is exhausted.

Note: Iff the pile is not closed yet, Next may block, awaiting some Pile().

func (*ListSPile) Pile

func (d *ListSPile) Pile(item []*list.List)

Pile appends an `[]*list.List` item to the ListSPile.

Note: Pile will block iff buff is exceeded and no Done() or Next()'s are used.

type Pile

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

Pile is a hybrid container for a lazily and concurrently populated growing-only slice of items (of type `*list.List`) which may be traversed in parallel to it's growth.

Usage for a pile `p`:

p := MakePile(128, 32)

Have it grow concurrently using multiple:

var item *list.List = something
p.Pile(item)

in as many go routines as You may seem fit.

In parallel, You may either traverse `p` in parallel right away:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

Here p.Iter() starts a new transversal with the first item (if any), and p.Next() keeps traverses the Pile.

or traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available:

r, p := <-p.Done(), nil

Hint: here we get the result in `r` and at the same time discard / deallocate / forget the pile `p` itself.

Note: The traversal is *not* intended to be concurrency safe! Thus: You may call `Pile` concurrently to Your traversal, but use of either `Done` or `Iter` and `Next` *must* be confined to a single go routine (thread).

func MakePile

func MakePile(size, buff int) *Pile

MakePile returns a (pointer to a) fresh pile of items (of type `*list.List`) with size as initial capacity and with buff as initial leeway, allowing as many Pile's to execute non-blocking before respective Done or Next's.

func (*Pile) Close

func (d *Pile) Close() (err error)

Close - call once when everything has been piled.

Close intentionally implements io.Closer

Note: After Close(), any Close(...) will panic and any Pile(...) will panic and any Done() or Next() will return immediately: no eventual blocking, that is.

func (*Pile) Done

func (d *Pile) Done() (done <-chan []*list.List)

Done returns a channel which emits the result (as slice of ) once the pile is closed.

Users of Done() *must not* iterate (via Iter() Next()...) before the done-channel is closed!

Done is a convenience - useful iff You do not like/need to start any traversal before the pile is fully populated. Once the pile is closed, Done() will signal in constant time.

Note: Upon signalling, the pile is reset to it's tip, so You may traverse it (via Next) right away. Usage for a pile `p`: Traverse blocking / awaiting close first:

for item := range <-p.Done() { ... do sth with item ... }

or use the result when available

r, p := <-p.Done(), nil

while discaring the pile itself.

func (*Pile) Iter

func (d *Pile) Iter() (item *list.List, ok bool)

Iter puts the pile iterator back to the beginning and returns the first `Next()`, iff any. Usage for a pile `p`:

for item, ok := p.Iter(); ok; item, ok = p.Next() { ... do sth with item ... }

func (*Pile) Next

func (d *Pile) Next() (item *list.List, ok bool)

Next returns the next item, or false iff the pile is exhausted.

Note: Iff the pile is not closed yet, Next may block, awaiting some Pile().

func (*Pile) Pile

func (d *Pile) Pile(item *list.List)

Pile appends an `*list.List` item to the Pile.

Note: Pile will block iff buff is exceeded and no Done() or Next()'s are used.

Jump to

Keyboard shortcuts

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