iter

package
v1.2.23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUnitIterator

func NewUnitIterator[T any](item T) *unitIterator[T]

NewUnitIterator construct an iterator over an array of items.

Types

type Iterator

type Iterator[T any] interface {
	enum.Enumerator[T]

	// Append another iterator onto the end of this iterator.  Thus, when all
	// items are visited in this iterator, iteration continues into the other.
	Append(Iterator[T]) Iterator[T]

	// Clone creates a copy of this iterator at the given cursor position.
	// Modifying the clone (i.e. by calling Next) iterator will not modify the
	// original.
	Clone() Iterator[T]

	// Collect allocates a new array containing all items of this iterator.
	// This drains the iterator.
	Collect() []T

	// Find returns the index of the first match for a given predicate, or
	// return false if no match is found.  This will mutate the iterator.
	Find(Predicate[T]) (uint, bool)

	// Count the number of items left.  Note, this does not modify the iterator.
	Count() uint
}

Iterator is an adapter which sits on top of a BaseIterator and provides various useful and reusable functions.

func NewAppendIterator

func NewAppendIterator[T any](left Iterator[T], right Iterator[T]) Iterator[T]

NewAppendIterator construct an iterator over an array of items.

func NewArrayIterator

func NewArrayIterator[T any](items []T) Iterator[T]

NewArrayIterator construct an iterator over an array of items.

func NewCastIterator

func NewCastIterator[S, T any](iter Iterator[S]) Iterator[T]

NewCastIterator construct an iterator over an array of items.

func NewFlattenIterator

func NewFlattenIterator[S, T any](iter Iterator[S], fn func(S) Iterator[T]) Iterator[T]

NewFlattenIterator adapts a sequence of items S which themselves can be iterated as items T, into a flat sequence of items T.

func NewProjectIterator

func NewProjectIterator[S, T any](iter Iterator[S], projection func(S) T) Iterator[T]

NewProjectIterator construct an iterator that is the projection of another.

func NewReverseArrayIterator

func NewReverseArrayIterator[T any](items []T) Iterator[T]

NewReverseArrayIterator constructs an iterator that yields the elements of items in reverse order, starting from the last element.

type Predicate

type Predicate[T any] = func(T) bool

Predicate abstracts the notion of a function which identifies something.

Jump to

Keyboard shortcuts

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