Content

com.phasmidsoftware.tableparser.core.table.Content
See theContent companion object
case class Content[+Row](xs: Vector[Row])

Class to represent the rows of a Table.

The rows are kept in a Vector, in order (as of 2.0; in 1.x, they were a ParIterable, in no particular order). For parallel processing, use par. The internal representation may change; thus xs is private.

In general, however, you should probably expect that storing rows inside Content will force an aggregation of all rows. There are alternatives (using InputProcessor) that allow you to process an Iterator[Input] and yield an Iterator[Row].

Type parameters

Row

the underlying Row type.

Value parameters

xs

a Vector[Row].

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def ++[B >: Row](other: Content[B]): Content[B]

Method to concatenate two Contents. CONSIDER perhaps we should use the combiner functionality more directly? (It's what the ++ method uses).

Method to concatenate two Contents. CONSIDER perhaps we should use the combiner functionality more directly? (It's what the ++ method uses).

Type parameters

B

the underlying type of the other Content and the result. Must be a super-type of Row.

Value parameters

other

the other Content.

Attributes

Returns

Content[B].

def drop(n: Int): Content[Row]

Drops the first n elements from the underlying collection xs and returns a new Content instance containing the remaining elements.

Drops the first n elements from the underlying collection xs and returns a new Content instance containing the remaining elements.

The method does not modify the original collection but instead creates a new Content instance with the result of the drop operation applied to xs.

Value parameters

n

the number of elements to drop from the start of the collection. If n is greater than the size of the collection, an empty Content is returned.

Attributes

Returns

a new Content[Row] containing the elements of the collection after dropping the first n elements.

def dropWhile(p: Row => Boolean): Content[Row]

Drops elements from this Content[Row] collection as long as the given predicate p evaluates to true, and returns the remaining elements wrapped in a new Content.

Drops elements from this Content[Row] collection as long as the given predicate p evaluates to true, and returns the remaining elements wrapped in a new Content.

The elements are checked in their order, and once the predicate returns false for the first time, no further elements are dropped, and the remaining elements are included in the resulting Content.

Value parameters

p

a predicate function of type Row => Boolean. This function determines whether an element should be dropped. Elements for which the predicate returns true are removed from the start of the collection.

Attributes

Returns

a new Content[Row] containing the elements of this Content after all leading elements satisfying the predicate p have been removed.

def filter(p: Row => Boolean): Content[Row]

Filters the rows in this content based on the given predicate.

Filters the rows in this content based on the given predicate.

Value parameters

p

a predicate function that determines whether a given Row should be included in the resulting Content. The function should return true for rows that should be included and false otherwise.

Attributes

Returns

a new Content[Row] containing only the rows from this content that satisfy the given predicate.

def filterNot(p: Row => Boolean): Content[Row]

Filters the rows of this Content[Row] by removing those that satisfy the given predicate function.

Filters the rows of this Content[Row] by removing those that satisfy the given predicate function.

Value parameters

p

the predicate function that determines whether a Row should be excluded. Rows for which this function evaluates to true will be excluded from the resulting Content.

Attributes

Returns

a new Content[Row] containing only the rows that do not satisfy the given predicate function.

def flatMap[B](f: Row => IterableOnce[B]): Content[B]

This is not, strictly speaking, the correct definition of flatMap for allowing Content to be a monad.

This is not, strictly speaking, the correct definition of flatMap for allowing Content to be a monad.

Type parameters

B

the underlying type of the result.

Value parameters

f

a function of type Row=>IterableOnce[B]

Attributes

Returns

a Content[B].

def foldLeft[B](z: B)(op: (B, Row) => B): B

Applies a binary operator to a start value and all elements of the underlying collection xs, going left to right, and returns a reduced value.

Applies a binary operator to a start value and all elements of the underlying collection xs, going left to right, and returns a reduced value.

This method performs a fold operation, where the initial value is provided by z and the binary operator op is applied successively to combine elements of the collection with the accumulated result.

Value parameters

op

A binary operator function that takes the current accumulated result and the next element of the collection, returning a new accumulated result. The function has the type (B, Row) => B, where B is the type of the accumulated result, and Row represents elements of the collection.

z

The initial value of the fold operation.

Attributes

Returns

The result of applying the fold operation over all elements of the collection. The result type is B.

def foreach(f: Row => Unit): Unit

Applies the given function f to each Row element in the collection.

Applies the given function f to each Row element in the collection.

This method iterates over all elements in the underlying sequence xs and applies the specified function f to each of them.

Value parameters

f

a function of type Row => Unit that is applied to each row in the collection. The function is invoked for its side effects on each element.

Attributes

Returns

Unit as this method is intended for side-effectful operations.

def head: Row

This should be used only by unit tests and not by code.

This should be used only by unit tests and not by code.

Attributes

Returns

the first element of xs.

def iterator: Iterator[Row]

Provides an iterator to traverse the rows in this content. NOTE: do not expect an iterator on Content to be in any particular order.

Provides an iterator to traverse the rows in this content. NOTE: do not expect an iterator on Content to be in any particular order.

Attributes

Returns

an Iterator over the Row elements of this content in their current order.

def knownSize: Int

Returns the known size of the collection underlying this Content instance. If the size is known, the method will return the exact size. Otherwise, it will return -1.

Returns the known size of the collection underlying this Content instance. If the size is known, the method will return the exact size. Otherwise, it will return -1.

Attributes

Returns

the known size of the collection, or -1 if the size cannot be determined.

infix def map[B](f: Row => B): Content[B]

Transforms each element in the current Content collection using the given function f.

Transforms each element in the current Content collection using the given function f.

Value parameters

f

A function that takes an element of type Row and produces a new element of type B.

Attributes

Returns

A new Content instance containing the transformed elements of type B.

def mapOptional[S](f: Row => Option[S]): Content[S]

Transform (flatMap) this Table[Row] into a Table[S].

Transform (flatMap) this Table[Row] into a Table[S].

Type parameters

S

the type of the rows of the result.

Value parameters

f

a function which transforms a Row into an IterableOnce[S].

Attributes

Returns

a Table[S] which is made up of a concatenation of the results of invoking f on each row this

def par: ParIterable[Row]

Method to get the rows as a parallel collection, for parallel processing. (As of 2.0, the other methods of Content are sequential.)

Method to get the rows as a parallel collection, for parallel processing. (As of 2.0, the other methods of Content are sequential.)

Attributes

Returns

a ParIterable[Row].

def sample(n: Int)(using random: Random): Content[Row]

Method to randomly sample from this Content.

Method to randomly sample from this Content.

Value parameters

n

the odds against choosing any particular element.

random

an (implicit) Random number generator.

Attributes

Returns

a new Content[Row] with approximately size/n elements.

def size: Int

Method to get the number of elements in the underlying collection xs.

Method to get the number of elements in the underlying collection xs.

Attributes

Returns

the size of the collection as an integer.

def slice(from: Int, until: Int): Content[Row]

Produces a slice of the content by extracting elements within the specified range.

Produces a slice of the content by extracting elements within the specified range.

This method creates a new Content[Row] that contains elements from index from (inclusive) to index until (exclusive) of the underlying collection xs. If the range specified by from and until exceeds the bounds of the underlying collection, the slicing will silently handle it and only include the valid indices.

Value parameters

from

the starting index (inclusive) of the slice.

until

the ending index (exclusive) of the slice.

Attributes

Returns

a new Content[Row] containing the elements in the specified range.

def sorted[S >: Row : Ordering]: Content[S]

Method to transform this Content[Row] into a sorted Content[S] where S is a super-class of Row and for which there is evidence of Ordering[S].

Method to transform this Content[Row] into a sorted Content[S] where S is a super-class of Row and for which there is evidence of Ordering[S].

Type parameters

S

the underlying type of the resulting Table (a super-type of Row and for which there is evidence of Ordering[S]).

Attributes

Returns

a Content[S].

def take(n: Int): Content[Row]

Returns a new Content[Row] containing the first n elements from the current Content[Row].

Returns a new Content[Row] containing the first n elements from the current Content[Row].

If n is greater than the size of the underlying collection, all elements from the collection will be included in the returned Content[Row]. If n is less than or equal to zero, the result will be an empty Content[Row].

Value parameters

n

the number of elements to take from the beginning of the underlying collection. Must be a non-negative integer.

Attributes

Returns

a new Content[Row] containing up to the first n elements from the current content.

def takeWhile(p: Row => Boolean): Content[Row]

Selects elements from the beginning of the underlying collection of rows, as long as they satisfy the specified predicate. The operation stops as soon as a row is encountered that does not meet the condition.

Selects elements from the beginning of the underlying collection of rows, as long as they satisfy the specified predicate. The operation stops as soon as a row is encountered that does not meet the condition.

Value parameters

p

a predicate function of type Row => Boolean that determines whether a row should be included. The function should return true to select the row and false to stop further selection.

Attributes

Returns

a new Content[Row] containing the rows from the start of the collection that satisfy the given predicate.

def toArray[B >: Row : ClassTag]: Array[B]

Converts the underlying collection of elements to an array.

Converts the underlying collection of elements to an array.

Type parameters

B

the type of elements in the resulting array. It must be a supertype of Row and have an implicit ClassTag.

Attributes

Returns

an array containing all elements of the collection.

def toIndexedSeq: IndexedSeq[Row]

Converts the content of xs into an IndexedSeq[Row].

Converts the content of xs into an IndexedSeq[Row].

Attributes

Returns

an IndexedSeq containing all elements of xs.

def toSeq: Seq[Row]

Converts the underlying collection of rows to a sequence.

Converts the underlying collection of rows to a sequence.

Attributes

Returns

a sequence (Seq[Row]) containing the rows of the content.

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product