Skip to content

kschuetz/enhanced-iterables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enhanced-iterables

enhanced-iterables Javadoc CircleCI Maintainability

Table of Contents

What is it?

enhanced-iterables is a Java library that is intended to be used in conjunction with lambda.

It provides interfaces that add some useful methods to Iterables. Most of these methods delegate to lambda functions, and return the most specific type of Iterable possible.

For more details, check out the javadoc.

lambda version compatibility

The current version of enhanced-iterables has been certified to be compatible with the following lambda versions:

  • 5.3.0
  • 5.2.0
  • 5.1.0
  • 5.0.0
  • 4.0.0

Types

The base functionality that can be added to any Iterable. Can be infinite, finite, or empty.

Methods

Method Returns Lambda function
append NonEmptyIterable<A> Snoc.snoc
concat EnhancedIterable<A> Concat.concat
drop EnhancedIterable<A> Drop.drop
dropWhile EnhancedIterable<A> DropWhile.dropWhile
filter EnhancedIterable<A> Filter.filter
find Maybe<A> Find.find
fmap EnhancedIterable<B> Map.map
intersperse EnhancedIterable<B> Intersperse.intersperse
isEmpty boolean --
magnetizeBy EnhancedIterable<NonEmptyIterable<A>> MagnetizeBy.magnetizeBy
partition Tuple2<EnhancedIterable<B>, EnhancedIterable<C>> Partition.partition
prepend NonEmptyIterable<A> Cons.cons
prependAll EnhancedIterable<A> PrependAll.prependAll
slide EnhancedIterable<NonEmptyFiniteIterable<A>> Slide.slide
span Tuple2<EnhancedIterable<A>, EnhancedIterable<A>> Span.span
take FiniteIterable<A> Take.take
takeWhile EnhancedIterable<A> TakeWhile.takeWhile
toArray A[] ToArray.toArray
toCollection C extends Collection<A> ToCollection.toCollection
zipWith EnhancedIterable<C> ZipWith.zipWith

Constructing

Any existing Iterable<A> can be converted to an EnhancedIterable<A> by calling the EnhancedIterable.enhance static method.

An EnhancedIterable that is known at compile-time to be finite.

Methods

In addition to all methods on EnhancedIterable<A>, provides the following:

Method Returns Lambda function
append NonEmptyFiniteIterable<A> Snoc.snoc
concat FiniteIterable<A> Concat.concat
cross FiniteIterable<Tuple2<A, B>>> CartestianProduct.cartesianProduct
cycle EnhancedIterable<A> Cycle.cycle
distinct FiniteIterable<A> Distinct.distinct
drop FiniteIterable<A> Drop.drop
dropWhile FiniteIterable<A> DropWhile.dropWhile
filter FiniteIterable<A> Filter.filter
fmap FiniteIterable<B> Map.map
foldLeft B FoldLeft.foldLeft
inits NonEmptyIterable<FiniteIterable<A>> Inits.inits
intersperse FiniteIterable<A> Intersperse.intersperse
magnetizeBy FiniteIterable<NonEmptyFiniteIterable<A>> MagnetizeBy.magnetizeBy
partition Tuple2<FiniteIterable<B>, FiniteIterable<C>> Partition.partition
prepend NonEmptyFiniteIterable<A> Cons.cons
prependAll FiniteIterable<A> PrependAll.prependAll
reverse FiniteIterable<A> Reverse.reverse
slide FiniteIterable<NonEmptyFiniteIterable<A>> Slide.slide
span Tuple2<FiniteIterable<A>, FiniteIterable<A>> Span.span
tails NonEmptyIterable<FiniteIterable<A>> Tails.tails
takeWhile FiniteIterable<A> TakeWhile.takeWhile
zipWith FiniteIterable<C> ZipWith.zipWith

Constructing

  • Any existing Collection<A> can be converted to a FiniteIterable<A> by calling the FiniteIterable.finiteIterable static method.
  • An Iterable<A> can converted to a FiniteIterable<A> by calling FiniteIterable.finiteIterable and providing a maximum size.

An EnhancedIterable that is known at compile-time to be non-empty. May be finite or infinite.

Methods

In addition to all methods on EnhancedIterable<A>, provides the following:

Method Returns Lambda function
concat NonEmptyIterable<A> Concat.concat
fmap NonEmptyIterable<B> Map.map
head A Head.head
intersperse NonEmptyIterable<A> Intersperse.intersperse
magnetizeBy NonEmptyIterable<NonEmptyIterable<A>> MagnetizeBy.magnetizeBy
prependAll NonEmptyIterable<A> PrependAll.prependAll
tail EnhancedIterable<A> Tail.tail
zipWith NonEmptyIterable<C> ZipWith.zipWith

Constructing

An Iterable<A> can converted to a NonEmptyIterable<A> by calling NonEmptyIterable.nonEmptyIterable and providing an additional element for the head.

An EnhancedIterable that is known at compile-time to be non-empty and finite.

Methods

In addition to all methods on FiniteIterable<A> and NonEmptyIterable<A>, provides the following:

Method Returns Lambda function
concat NonEmptyFiniteIterable<A> Concat.concat
cross NonEmptyFiniteIterable<Tuple2<A, B>>> CartestianProduct.cartesianProduct
cycle NonEmptyIterable<A> Cycle.cycle
distinct NonEmptyFiniteIterable<A> Distinct.distinct
fmap NonEmptyFiniteIterable<B> Map.map
init FiniteIterable<A> Init.init
intersperse NonEmptyFiniteIterable<A> Intersperse.intersperse
last A Last.last
magnetizeBy NonEmptyFiniteIterable<NonEmptyFiniteIterable<A>> MagnetizeBy.magnetizeBy
prependAll NonEmptyFiniteIterable<A> PrependAll.prependAll
reverse NonEmptyFiniteIterable<A> Reverse.reverse
tail FiniteIterable<A> Tail.tail
zipWith NonEmptyFiniteIterable<C> ZipWith.zipWith

Constructing

A FiniteIterable<A> can converted to a NonEmptyFiniteIterable<A> by calling NonEmptyFiniteIterable.nonEmptyFiniteIterable and providing an additional element for the head.

An EnhancedIterable that is known at compile-time to be safe from mutation. May be empty, finite, or infinite.

Methods

In addition to all methods on EnhancedIterable<A>, provides the following:

Method Returns Lambda function
append ImmutableNonEmptyIterable<A> Snoc.snoc
concat ImmutableIterable<A> Concat.concat
drop ImmutableIterable<A> Drop.drop
dropWhile ImmutableIterable<A> DropWhile.dropWhile
filter ImmutableIterable<A> Filter.filter
fmap ImmutableIterable<B> Map.map
intersperse ImmutableIterable<B> Intersperse.intersperse
magnetizeBy ImmutableIterable<ImmutableNonEmptyIterable<A>> MagnetizeBy.magnetizeBy
partition Tuple2<ImmutableIterable<B>, ImmutableIterable<C>> Partition.partition
prepend ImmutableNonEmptyIterable<A> Cons.cons
prependAll ImmutableIterable<A> PrependAll.prependAll
slide ImmutableIterable<ImmutableNonEmptyFiniteIterable<A>> Slide.slide
span Tuple2<ImmutableIterable<A>, ImmutableIterable<A>> Span.span
take ImmutableFiniteIterable<A> Take.take
takeWhile ImmutableIterable<A> TakeWhile.takeWhile
zipWith ImmutableIterable<C> ZipWith.zipWith

Constructing

  • ImmutableIterable.of static method
  • ImmutableIterable.copyFrom static method constructs ImmutableFiniteIterables by copying from existing finite iterables (such as Collections)
  • The collection-views library provides some implementations of ImmutableIterable (e.g. ImmutableVector).

An EnhancedIterable that is known at compile-time to be safe from mutation and finite. May be empty.

Methods

In addition to all methods on ImmutableIterable<A> and FiniteIterable<A>, provides the following:

Method Returns Lambda function
append ImmutableNonEmptyFiniteIterable<A> Snoc.snoc
concat ImmutableFiniteIterable<A> Concat.concat
cross ImmutableFiniteIterable<Tuple2<A, B>>> CartestianProduct.cartesianProduct
cycle ImmutableIterable<A> Cycle.cycle
distinct ImmutableFiniteIterable<A> Distinct.distinct
drop ImmutableFiniteIterable<A> Drop.drop
dropWhile ImmutableFiniteIterable<A> DropWhile.dropWhile
filter ImmutableFiniteIterable<A> Filter.filter
fmap ImmutableFiniteIterable<B> Map.map
intersperse ImmutableFiniteIterable<B> Intersperse.intersperse
magnetizeBy ImmutableFiniteIterable<ImmutableNonEmptyFiniteIterable<A>> MagnetizeBy.magnetizeBy
partition Tuple2<ImmutableFiniteIterable<B>, ImmutableFiniteIterable<C>> Partition.partition
prepend ImmutableNonEmptyFiniteIterable<A> Cons.cons
prependAll ImmutableFiniteIterable<A> PrependAll.prependAll
reverse ImmutableFiniteIterable<A> Reverse.reverse
slide ImmutableFiniteIterable<ImmutableNonEmptyFiniteIterable<A>> Slide.slide
span Tuple2<ImmutableFiniteIterable<A>, ImmutableFiniteIterable<A>> Span.span
tails NonEmptyIterable<ImmutableFiniteIterable<A>> Tails.tails
takeWhile ImmutableFiniteIterable<A> TakeWhile.takeWhile
zipWith ImmutableFiniteIterable<C> ZipWith.zipWith

Constructing

  • ImmutableFiniteIterable.of static method
  • ImmutableIterable.copyFrom static method constructs ImmutableFiniteIterables by copying from existing finite iterables (such as Collections)
  • The collection-views library provides some implementations of ImmutableFiniteIterable (e.g. ImmutableVector).

An EnhancedIterable that is known at compile-time to be safe from mutation and non-empty. May be finite or infinite.

Methods

In addition to all methods on ImmutableIterable<A> and NonEmptyIterable<A>, provides the following:

Method Returns Lambda function
concat ImmutableNonEmptyIterable<A> Concat.concat
fmap ImmutableNonEmptyIterable<B> Map.map
intersperse ImmutableNonEmptyIterable<A> Intersperse.intersperse
magnetizeBy ImmutableNonEmptyIterable<ImmutableNonEmptyIterable<A>> MagnetizeBy.magnetizeBy
prependAll ImmutableNonEmptyIterable<A> PrependAll.prependAll
tail ImmutableIterable<A> Tail.tail
zipWith ImmutableNonEmptyIterable<C> ZipWith.zipWith

Constructing

  • ImmutableNonEmptyIterable.of static method
  • An ImmutableIterable<A> can converted to a ImmutableNonEmptyIterable<A> by calling ImmutableNonEmptyIterable.immutableNonEmptyIterable and providing an additional element for the head.
  • The collection-views library provides some implementations of ImmutableNonEmptyIterable (e.g. ImmutableNonEmptyVector).

An EnhancedIterable that is known at compile-time to be safe from mutation, non-empty, and finite.

Methods

In addition to all methods on ImmutableFiniteIterable<A> and ImmutableNonEmptyIterable<A>, provides the following:

Method Returns Lambda function
concat ImmutableNonEmptyFiniteIterable<A> Concat.concat
cross ImmutableNonEmptyFiniteIterable<Tuple2<A, B>>> CartestianProduct.cartesianProduct
cycle ImmutableNonEmptyIterable<A> Cycle.cycle
distinct ImmutableFiniteIterable<A> Distinct.distinct
fmap ImmutableNonEmptyFiniteIterable<B> Map.map
init ImmutableFiniteIterable<A> Init.init
intersperse ImmutableNonEmptyFiniteIterable<B> Intersperse.intersperse
magnetizeBy ImmutableFiniteIterable<ImmutableNonEmptyFiniteIterable<A>> MagnetizeBy.magnetizeBy
prependAll ImmutableNonEmptyFiniteIterable<A> PrependAll.prependAll
reverse ImmutableNonEmptyFiniteIterable<A> Reverse.reverse
zipWith ImmutableNonEmptyFiniteIterable<C> ZipWith.zipWith

Constructing

  • ImmutableNonEmptyFiniteIterable.of static method
  • An ImmutableFiniteIterable<A> can converted to a ImmutableNonEmptyFiniteIterable<A> by calling ImmutableNonEmptyFiniteIterable.immutableNonEmptyFiniteIterable and providing an additional element for the head.
  • The collection-views library provides some implementations of ImmutableNonEmptyFiniteIterable (e.g. ImmutableNonEmptyVector).

FOSSA Status

enhanced-iterables is distributed under The MIT License.

The MIT License (MIT)

Copyright © 2019 Kevin Schuetz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.