-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.0] New collection methods #1010
Changes from all commits
7ccce9a
2fa224b
b17c8c8
fc3be57
acb76c9
877ed78
9fd499a
8136c8f
d738ac5
1989d19
6459b07
5c4ccf1
1d47d5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,19 @@ trait Coll[@specialized A] { | |
*/ | ||
def apply(i: Int): A | ||
|
||
/** The element at given index or None if there is no such element. Indices start at `0`. | ||
* | ||
* @param i the index | ||
* @return the element at the given index, or None if there is no such element | ||
*/ | ||
def get(i: Int): Option[A] = { | ||
if (isDefinedAt(i)) { | ||
Some(apply(i)) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
/** Tests whether this $coll contains given index. | ||
* | ||
* The implementations of methods `apply` and `isDefinedAt` turn a `Coll[A]` into | ||
|
@@ -76,6 +89,18 @@ trait Coll[@specialized A] { | |
* produces a collection ((x0, y0), ..., (xK, yK)) where K = min(N, M) */ | ||
def zip[@specialized B](ys: Coll[B]): Coll[(A, B)] | ||
|
||
/** | ||
* @return true if first elements of this collection form given `ys` collection, false otherwise. | ||
* E.g. [1,2,3] starts with [1,2] | ||
*/ | ||
def startsWith(ys: Coll[A]): Boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ScalaDoc is not correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
/** | ||
* @return true if last elements of this collection form given `ys` collection, false otherwise. | ||
* E.g. [1,2,3] ends with [2,3] | ||
*/ | ||
def endsWith(ys: Coll[A]): Boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ScalaDoc is not correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
/** Tests whether a predicate holds for at least one element of this collection. | ||
* @param p the predicate used to test elements. | ||
* @return `true` if the given predicate `p` is satisfied by at least one element of this collection, otherwise `false` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScalaDoc doesn't correspond to the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed