An ordered batch-type object that requires there to always be at least one element present, ruling out the possibility of unsafely accessing the head
element.
Type parameters
- A
-
The type of element to be stored in the batch.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Concatenate two NonEmptyBatch
's together
Concatenate two NonEmptyBatch
's together
Value parameters
- other
-
A second NonEmptyBatch of the same type
Attributes
- Returns
-
A new NonEmptyBatch containing the elements of both lists
Concatenate a NonEmptyBatch
with a Batch
Concatenate a NonEmptyBatch
with a Batch
Value parameters
- other
-
A Batch of the same type
Attributes
- Returns
-
A new NonEmptyBatch containing the elements of both lists
Append an element
Append an element
Value parameters
- next
-
The next element of the same type
Attributes
- Returns
-
NonEmptyBatch[A]
Prepend an element
Prepend an element
Value parameters
- first
-
The new head element of the same type
Attributes
- Returns
-
NonEmptyBatch[A]
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
x
of typeAny
,x.equals(x)
should returntrue
. - It is symmetric: for any instances
x
andy
of typeAny
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any instances
x
,y
, andz
of typeAny
ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
.
If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode
to ensure that objects which are "equal" (o1.equals(o2)
returns true
) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)
).
Value parameters
- that
-
the object to compare against this object for equality.
Attributes
- Returns
-
true
if the receiver object is equivalent to the argument;false
otherwise. - Definition Classes
-
Equals -> Any
Batch find, but only returns a Boolean indicating if an element matching the predicate was found.
Batch find, but only returns a Boolean indicating if an element matching the predicate was found.
Value parameters
- p
-
Predicate function
Attributes
- Returns
-
Boolean
Search the NonEmptyBatch using a predicate and return the first element that matches
Search the NonEmptyBatch using a predicate and return the first element that matches
Value parameters
- p
-
Predicate, returns the first elements for which this predicate holds true
Attributes
- Returns
-
Optional A, if no match can be found None is returned.
Alias for head
Alias for head
Attributes
- Returns
-
A
Apply a function f
to each element of the batch to produce a new batch. Differs from map because f produces another NonEmptyBatch, which is then flattened. Useful in monadic comprehensions.
Apply a function f
to each element of the batch to produce a new batch. Differs from map because f produces another NonEmptyBatch, which is then flattened. Useful in monadic comprehensions.
Type parameters
- B
-
Resultant type of the new NonEmptyBatch
Value parameters
- f
-
function to apply to each element
Attributes
- Returns
-
A NonEmptyBatch of a potentially different type
- Example
-
NonEmptyBatch(1, 2, 3).flatMap(i => NonEmptyBatch(i * 10))
results inNonEmptyBatch(10, 20, 30)
foldLeft
differs from reduce it two important ways:
foldLeft
differs from reduce it two important ways:
- It has an initial value onto which all other values are applied
- It does not require the result type to be the same as the batch type.
Type parameters
- Z
-
The accumulator type
Value parameters
- acc
-
The initial accumulator value to accumulate against
- f
-
A function for combining the accumulator and the next value
Attributes
- Returns
-
the final accumulated value
- Example
-
NonEmptyBatch(1, 2, 3)("")((a, b) => a + b) results in "123"
Checks that a predicate holds for all elements
Checks that a predicate holds for all elements
Value parameters
- p
-
Predicate function
Attributes
- Returns
-
Boolean
Returns the last element in the batch
Returns the last element in the batch
Attributes
- Returns
-
A
A count of the elements in the batch
A count of the elements in the batch
Attributes
- Returns
-
Int
Apply a function f
to each element of the batch to produce a new batch.
Apply a function f
to each element of the batch to produce a new batch.
Type parameters
- B
-
Resultant type of the new NonEmptyBatch
Value parameters
- f
-
function to apply to each element
Attributes
- Returns
-
A NonEmptyBatch of a potentially different type
- Example
-
NonEmptyBatch(1, 2, 3).map(_ * 10)
results inNonEmptyBatch(10, 20, 30)
Delegates to mkString(separator: String): String
Delegates to mkString(separator: String): String
Attributes
- Returns
-
String
Converts the batch into a String
Converts the batch into a String
Value parameters
- separator
-
A string to add between the elements
Attributes
- Returns
-
String
Converts the batch into a String
Converts the batch into a String
Value parameters
- prefix
-
A string to add before the elements
- separator
-
A string to add between the elements
- suffix
-
A string to add after the elements
Attributes
- Returns
-
String
Value parameters
- f
-
a function for combining to
A
's into a singleA
Attributes
- Returns
-
The final
A
value - Example
-
NonEmptyBatch(1, 2, 3)((a, b) => a + b) results in 6
Reverse the order of the batch
Reverse the order of the batch
Attributes
- Returns
-
NonEmptyBatch[A]
A count of the elements in the batch
A count of the elements in the batch
Attributes
- Returns
-
Int
Converts the NonEmptyBatch back to a regular Batch.
Converts the NonEmptyBatch back to a regular Batch.
Attributes
Converts the NonEmptyBatch back to a List.
Converts the NonEmptyBatch back to a List.
Attributes
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Definition Classes
-
Any
Takes two NonEmptyBatchs and creates a new NonEmptyBatch of the elements of both inputs tupled together.
Takes two NonEmptyBatchs and creates a new NonEmptyBatch of the elements of both inputs tupled together.
Type parameters
- B
-
The type of the second NonEmptyBatch
Value parameters
- other
-
The second NonEmptyBatch to zip with.
Attributes
- Returns
-
NonEmptyBatch[(A, B)]
- Example
-
NonEmptyBatch("a", "b", "c").zip(NonEmptyBatch(1, 2, 3))
results inNonEmptyBatch(("a", 1), ("b", 2), ("c", 3))
Attributes
- Example
-
NonEmptyBatch("a", "b", "c").zipWithIndex
results inNonEmptyBatch(("a", 0), ("b", 1), ("c",2))
Inherited methods
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product