scalax.data.collection

object collection

object collection

 extends ScalaObject




Source: collection.scala(12)

Nested Classes

And, BoolTree, FilterMap, IdMapper, Leaf, Not, Or, RichMap, RichStream, TreeNode, XIterator, XPair,

 Constructors

def this

 Fields

Tree object Tree
A simple tree class where each node (Tree) is a Leaf or a Branch, and each Branch contains a list of other Trees


 extends ScalaObject

 Methods

!= final def !=(arg0 : Any) Boolean Any
!= final def !=(arg0 : Object) Boolean AnyRef
== final def ==(arg0 : Object) Boolean AnyRef
== final def ==(arg0 : Any) Boolean Any
Iterable2FilterMap implicit def Iterable2FilterMap[T](s : Iterable[T]) FilterMap[T]
Iterable2Iterator implicit def Iterable2Iterator[T](s : Iterable[T]) Iterator[T]
Iterator2FilterMap implicit def Iterator2FilterMap[T](s : Iterator[T]) FilterMap[T]
Iterator2XIterator implicit def Iterator2XIterator[T](s : Iterator[T]) XIterator[T]
MapToRichMap implicit def MapToRichMap[k, v](m : Map[k, v]) RichMap[k, v]
RichMapToMap implicit def RichMapToMap[k, v](m : RichMap[k, v]) Map[k, v]
RichStreamToStream implicit def RichStreamToStream[a](s : RichStream[a]) Stream[a]
StreamToRichStream implicit def StreamToRichStream[a](s : Stream[a]) RichStream[a]
all def all(xs : Seq[Boolean])
Same as xs forall (x => x)
Boolean
argmax def argmax(xs : Seq[Int]) (Int, Int)
argmin def argmin(xs : Seq[Int]) (Int, Int)
argmin def argmin[a, b <: Ordered[b]](xs : Iterator[a])(f : (a) => b) (a, b, Int)
argminId def argminId[a <: Ordered[a]](xs : Iterator[a])
A specialization of argmin that uses the identity function as the comparison key [details]

argminId([b,a,c]) == (a,1)

argminId([]) == error

(a, a, Int)
asInstanceOf final def asInstanceOf[T0] T0 Any
camelToHyphen def camelToHyphen(s : String) String
camelToLower def camelToLower(s : String, sep : String)
Convert camel case to lower case with the given inter-word glue string [details]

camelToLower("helloWorld", "_") == "hello_world"

camelToLower("HelloWorld", "_") == "_hello_world"

String
camelToSpaced def camelToSpaced(s : String) String
camelToUnder def camelToUnder(s : String) String
chunks def chunks[a](n : Int)(xs : Seq[a])
Return all length-n "chunks" of xs as a stream [details]

chunks(3)([a..h]) == [[a,b,c],[d,e,f],[g,h]]

Stream[Seq[a]]
clone protected def clone Object AnyRef
concat def concat[a](iters : Seq[Iterator[a]])
Concatenate iterators
Iterator[a]
coord def coord[a](i : Int, xss : Iterable[Seq[a]])
Get the i-th element of a flatten list of lists [details]

coord(7, [[a,b],[],[c,d,e],[f],[g,h,i],[j,k]]) == h

deprecated
- Use instead: xss.flatMap(x=>x)(0).
(Int, Int)
dropWhile def dropWhile[a](iter : Iterator[a])(p : (a) => Boolean)
The standard library Iterator [details]
dropWhile is inefficient and non-scalable, as it is recursive. This is an efficient (tail-recursive) implementation.
Iterator[a]
eq final def eq(arg0 : Object) Boolean AnyRef
equals def equals(arg0 : Any) Boolean AnyRef
finalize protected def finalize Unit AnyRef
getClass final def getClass Class[Any] AnyRef
groupBy def groupBy[a](xs : Seq[a])(pred : (a) => Boolean)
Same as splitBy, but uses the negation of the pred [details]
Note that this is quite different from Haskell's groupBy.

groupBy([1,2,3,4,5], (_ % 4 < 2)) == [[1],[4,5],[8,9]]

Stream[Seq[a]]
groupByHeaders def groupByHeaders[a](xs : Seq[a])(p : (a) => Boolean)
For each x in xs, if p(x), then x is a header, and it owns all the xs after it until the next x for which p(x) holds [details]
The return value is the header and its body.

groupByHeaders([1,2,3,4,5,6,7,8,9])(_%3==0) == [[3,4,5],[6,7,8],[9]]

ArrayBuffer[ArrayBuffer[a]]
groupPairwiseBy def groupPairwiseBy[a](xs : Seq[a])(pred : (a, a) => Boolean)
Same as Haskell's groupBy [details]
Groups together equal elements, letting the user supply a custom equality test. Note this is quite different from groupBy/splitBy.

groupPairwiseBy([1..9], (_/3 == _/3)) == [[1,2],[3,4,5],[6,7,8],[9]]]

List[List[a]]
hashCode def hashCode Int AnyRef
hist def hist[a](xs : Iterator[a])
Given an iterator, return a HashMap from each distinct element to its count
HashMap[a, Int]
indexGroups def indexGroups[a, b](xs : Seq[a])(f : (a) => b)
Indexes the result of groupBy [details]

[0 1 2 3 4 5 6 7 8 9]
[a,b,c,c,c,d,d,e,f,f] == [[0],[1],[2,3,4],[5,6],[7],[8,9]]

[] == []

Stream[Stream[Int]]
isInstanceOf final def isInstanceOf[T0] Boolean Any
iterator2array def iterator2array[a](xs : Iterator[a])
Convert an iterator to array
Array[a]
lastIndexWhere def lastIndexWhere[a](seq : Seq[a])(pred : (a) => Boolean)
Find the index of the last element in the sequence that satisfies the given predicate
Int
mean def mean(xs : Seq[Int]) Int
mean def mean(xs : Seq[Double]) Double
meanAndVariance def meanAndVariance(xs : Seq[Double])
Return a tuple of the mean and variance of the given sequence
(Double, Double)
median def median(xs : Seq[Long]) Long
merge def merge[a, b <: Ordered[b]](streams : Seq[BufferedIterator[a]])(f : (a) => b)
Sort-merge streams [details]
Assumes that the stream are each sorted already.
Stream[a]
mins def mins(xs : Iterable[Long])
Return the two smallest elements
(Long, Long)
mod def mod(n : Int, m : Int)
Return the positive (unsigned int) modulo
Int
mostPopular def mostPopular[a](xs : Iterator[a])
Return a list of the most popular element [details]
An arbitrary element may be returned in case of ties.
a
multimap def multimap[a, b](xs : Iterable[(a, b)])
Construct a multimap out of the given key-value pairs; the result maps keys to sets of values
HashMap[a, Set[b]] with MultiMap[a, b]
ne final def ne(arg0 : Object) Boolean AnyRef
newArrayBuffer def newArrayBuffer[a](xs : Iterator[a])
Convenience constructor for converting an Iterator into an ArrayBuffer [details]
deprecated
- Use instead: xs.toElements.
ArrayBuffer[a]
not def not[a](pred : (a) => Boolean)(x : a)
Negat a predicate function
Boolean
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
orderedMultimap def orderedMultimap[a, b](xs : List[(a, b)])
Construct a multimap out of xs, preserving the order of values as they were input
HashMap[a, ArrayBuffer[b]]
pad def pad[a](n : Int, e : => a, s : Iterator[a])
Return a stream of length at least n whose first elements are from the given iterator, but if the iterator has fewer than n elements, then the remaining elements are repeat(gen)
Stream[a]
pair2xpair implicit def pair2xpair(p : (Int, Int)) XPair
pairs def pairs[a](xs : Seq[a])
Return pairs of elements [details]

pairs([a,b,c,d]) == [(a,b),(c,d)]

pairs([a,b,c,d,e]) == [(a,b),(c,d)]

Stream[(a, a)]
pairwise def pairwise[a](xs : Iterable[a])
Same as slices(_,2) but yields tuples [details]

pairwise([a,b,c]) == [(a,b),(c,d)]

pairwise([a]) == []

pairwise([]) == []

Iterator[(a, a)]
repeat def repeat[a](gen : => a)
Return an infinite stream, where each element is an evaluation of gen
Stream[a]
replicate def replicate[a](n : Int, gen : => a)
Return a stream of n elements, where each element is an evaluation of gen [details]

Note that gen may be evaluated more than n times. See "How to add laziness to a strict language, without even being odd"

Stream[a]
rot def rot(n : Int, s : String)
Rot-n-encode a string, but where all characters are rotated, not just alphabetical characters
String
separateHeads def separateHeads[a](xss : Seq[Seq[a]])
Given a list of sublists, return pairs of the first element of each sublist along with the remaining elements [details]
Empty sublists are ignored.

separateHeads([[a,b,c],[d,e,f,g],[],[h]]) == [(a,[b,c]),(d,[e,f,g]),(h,[])]

Seq[(a, Seq[a])]
serializeInt def serializeInt(i : Int)
Serialize an Int to a String of four bytes (little-endian)
String
slices def slices[a](xs : Seq[a], n : Int)
Return all length-n slices of xs [details]

slice([a,b,c,d,e], 3) == [[a,b,c],[b,c,d],[c,d,e]]

Projection[Seq[a]]
sortCounts def sortCounts[a](xs : Array[(a, Int)])
Destructively sort the array by the tuples' second elements, and return the array
Array[(a, Int)]
sortCounts def sortCounts[a](h : Map[a, Int])
Return an array of the mappings in the Map, sorted by their entry-values
Seq[(a, Int)]
sortStats def sortStats(xs : Array[Double])
Destructively sort the array, and returns a tuple of the (mean, median, standard deviation, variance, minimum, and maximum) of a list
(Double, Double, Double, Double, Double, Double)
spacedToHyphen def spacedToHyphen(s : String)
Convert a spaced word to a hyphenated word
String
span def span[a](n : Int)(xs : Seq[a])
A combination of take and drop [details]

span(3)([a,b,c,d,e]) == ([a,b,c],[d,e])

(Seq[a], Seq[a])
spanBy def spanBy[a](xs : Seq[a])(pred : (a) => Boolean)
A combination of takeWhile and dropWhile [details]

spanBy([1,2,3,4,5])((_ != 3)) == ([1,2],[3,4,5])

(Seq[a], Seq[a])
spanstr def spanstr[a](n : Int)(xs : String)
Same as span but for Strings, which are treated as an array of chars [details]

spanstr(3)("abcde") == ("abc","de")

(String, String)
splitBy def splitBy[a](xs : Seq[a])(pred : (a) => Boolean)
Split up the sequence by the given predicate [details]
Similar to String.split, but matching is per-element.

splitBy([1..10], (_ % 4 < 2)) == [[2,3],[6,7],[8,9]]

[1,3,5,6,7,8] odd == ([1,3,5],[6,7,8])

[] _ == ([],[])

Stream[Seq[a]]
str def str(xs : Iterable[Char])
[details]
deprecated
- Use Iterable mkString ""
String
sum def sum(xs : Seq[Double]) Double
sum def sum(xs : Iterator[Int]) Int
sum def sum(xs : Iterator[Double]) Double
swap def swap[a, b](p : (a, b))
Swap the elements of a tuple
(b, a)
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
take def take[a](src : Seq[a], n : Int)
Take an elements from a list
Array[a]
toString def toString String AnyRef
topHist def topHist[a](xs : Iterator[a], n : Int)
Return a list of the most popular elements along with their histogram counts
(HashMap[a, Int], Seq[(a, Int)])
truncateWhile def truncateWhile[a](seq : Seq[a])(pred : (a) => Boolean)
Truncate elements off the end of the sequence that satisfy the given predicate [details]
A reverse dropWhile.

truncateWhile([1,2,3,4,5], (_ != 3)) == [1,2,3]

Seq[a]
uniq def uniq[a](xs : Seq[a])
Eliminate consecutive duplicates
List[a]
untilNull def untilNull[a](f : => a)
Return an iterator that yields invocations of f until it returns null [details]
Useful for, e.g., Java's IO stream abstractions.
Iterator[a]
unzip def unzip[a, b](pairs : Stream[(a, b)])
Given a Stream of pairs, return two Streams over the first and second elements of the pairs
(Stream[a], Stream[b])
unzip def unzip[a, b](pairs : Iterator[(a, b)])
Given an Iterator of pairs, return two Iterators over the first and second elements of the pairs [details]
Note that this operates by duplicating the iterator and traversing each copy.
(Iterator[a], Iterator[b])
wait final def wait Unit AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
words def words(x : String)
Split a String into words [details]
Use this when possible, since its implementation may become more efficient than the regex-based String.split() in the future.
Array[String]
xpair2pair implicit def xpair2pair(p : XPair) (Int, Int)
zipx def zipx[a](xss : Seq[Iterable[a]])
Zip or unzip some lists (the zip width is dynamic, so no tuples) [details]
The length of the resulting list is the length of the shortest input list.

zipx([[a,b,c,d,e],[f,g,h,i,j],[k,l,m,n]]) == [[a,f,k],[b,g,l],[c,h,m],[d,i,n]]

unzipx([[a,f,k],[b,g,l],[c,h,m],[d,i,n]]) == [[a,b,c,d],[f,g,h,i],[k,l,m,n]]

Stream[Seq[a]]
zipx def zipx[a](xss : Iterable[Seq[a]])
Zip or unzip some lists (the zip width is dynamic, so no tuples) [details]
The length of the resulting list is the length of the shortest input list.
List[Iterator[a]]
Copyright (c) 2005-2008. All Rights Reserved.