final class NumericString extends AnyVal
An AnyVal for numeric Strings.
Note: a NumericString contains only numeric digit characters.
Because NumericString is an AnyVal
it will usually be as efficient as a String, being
boxed only when a String would have been boxed.
The NumericString.apply factory method is implemented in
terms of a macro that checks literals for validity at compile time. Calling
NumericString.apply with a literal String value
will either produce a valid NumericString instance at run
time or an error at compile time. Here's an example:
scala> import anyvals._
import anyvals._
scala> NumericString("42")
res0: org.scalactic.anyvals.NumericString = NumericString(42)
scala> NumericString("abc")
<console>:11: error: NumericString.apply can only be invoked on String literals that contain numeric characters, i.e., decimal digits '0' through '9', like "123".
NumericString("abc")
^
NumericString.apply cannot be used if the value being passed
is a variable (i.e., not a literal), because the macro cannot
determine the validity of variables at compile time (just literals). If
you try to pass a variable to NumericString.apply, you'll
get a compiler error that suggests you use a different factory method,
NumericString.from, instead:
scala> val x = "1"
x: String = 1
scala> NumericString(x)
<console>:15: error: NumericString.apply can only be invoked on String literals that contain only numeric characters, i.e., decimal digits '0' through '9', like "123" Please use NumericString.from instead.
NumericString(x)
^
The NumericString.from factory method will inspect the value
at runtime and return an Option[NumericString]. If
the value is valid, NumericString.from will return a
Some[NumericString], else it will return a None.
Here's an example:
scala> NumericString.from(x) res3: Option[org.scalactic.anyvals.NumericString] = Some(NumericString(1)) scala> val y = "a" y: String = a scala> NumericString.from(y) res4: Option[org.scalactic.anyvals.NumericString] = None
- Source
- NumericString.scala
- Alphabetic
- By Inheritance
- NumericString
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- def *(n: Int): NumericString
Return a
NumericStringconsisting of the currentNumericStringconcatenatedntimes. - def ++(that: String): String
Returns a new
Stringconcatenating thisNumericStringwith the passedString.Returns a new
Stringconcatenating thisNumericStringwith the passedString.- that
the
Stringto append- returns
a new
Stringwhich contains all elements of thisNumericStringfollowed by all elements of that
- def ++:(that: String): String
Returns a new
Stringconsisting of thisNumericStringprepended by the passedString.Returns a new
Stringconsisting of thisNumericStringprepended by the passedString.- that
the
Stringto append- returns
a new
Stringwhich contains all elements of that followed by all elements of thisNumericString
- def +:(elem: Char): String
Returns a new
Stringconsisting of thisNumericStringprepended by the passedChar.Returns a new
Stringconsisting of thisNumericStringprepended by the passedChar.- elem
the prepended
Char- returns
a new
Stringconsisting ofelemfollowed by all characters from thisNumericString
- def /:(z: Int)(op: (Int, Char) => Int): Int
Applies a binary operator to a start value and all elements of this
NumericString, going left to right.Applies a binary operator to a start value and all elements of this
NumericString, going left to right.Note:
/:is alternate syntax forfoldLeft;z /: xsis the same asxs foldLeft z.- z
the start value
- op
the binary operator
- returns
the result of inserting
opbetween consecutiveCharsof thisNumericString, going left to right with the start valuezon the left:op(...op(op(z, x_1), x_2), ..., x_n)
where
x1, ..., xnare the characters of thisNumericString.
- def :+(elem: Char): String
Returns a new
Stringconsisting of thisNumericStringwith the passedCharappended.Returns a new
Stringconsisting of thisNumericStringwith the passedCharappended.- elem
the appended
Char- returns
a new
Stringconsisting of all elements of thisNumericStringfollowed byelem
- def :\(z: Int)(op: (Char, Int) => Int): Int
Applies a binary operator to all elements of this
NumericStringand a start value, going right to left.Applies a binary operator to all elements of this
NumericStringand a start value, going right to left.Note: :\ is alternate syntax for foldRight; xs :\ z is the same as xs foldRight z.
- z
the start value
- op
the binary operator
- returns
the result of inserting
opbetween consecutive characters of thisNumericString, going right to left with the start valuezon the right:op(x_1, op(x_2, ... op(x_n, z)...))
where
x1, ..., xnare the characters of thisNumericString.
- def <(that: String): Boolean
Returns true if
thisis less thanthat - def <=(that: String): Boolean
Returns true if
thisis less than or equal tothat - final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- def >(that: String): Boolean
Returns true if
thisis greater thanthat - def >=(that: String): Boolean
Returns true if
thisis greater than or equal tothat - def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder
Appends character elements of this
NumericStringto a string builder using start, separator, and end strings.Appends character elements of this
NumericStringto a string builder using start, separator, and end strings. The written text begins with the stringstartand ends with the stringend. Inside, the characters of thisNumericStringare separated by the stringsep.- b
the string builder to which elements are appended
- start
the starting string
- sep
the separator string
- end
the ending string
- returns
the string builder b to which elements were appended
- def addString(b: StringBuilder, sep: String): StringBuilder
Appends character elements of this
NumericStringto a string builder using a separator string.Appends character elements of this
NumericStringto a string builder using a separator string.- b
the string builder to which elements are appended
- sep
the separator string
- returns
the string builder b to which elements were appended
- def addString(b: StringBuilder): StringBuilder
Appends string value of this
NumericStringto a string builder.Appends string value of this
NumericStringto a string builder.- b
the string builder to which this
NumericStringgets appended- returns
the string builder b to which this
NumericStringwas appended
- def aggregate[B](z: => B)(seqop: (B, Char) => B, combop: (B, B) => B): B
Aggregates the results of applying an operator to subsequent elements of this
NumericString.Aggregates the results of applying an operator to subsequent elements of this
NumericString.This is a more general form of
foldandreduce. It is similar tofoldLeftin that it doesn't require the result to be a supertype of the element type.aggregatesplits the elements of thisNumericStringinto partitions and processes each partition by sequentially applyingseqop, starting withz(likefoldLeft). Those intermediate results are then combined by usingcombop(likefold). The implementation of this operation may operate on an arbitrary number of collection partitions (even 1), socombopmay be invoked an arbitrary number of times (even 0).As an example, consider summing up the integer values the character elements. The initial value for the sum is 0. First,
seqoptransforms each input character to an Int and adds it to the sum (of the partition). Then,combopjust needs to sum up the intermediate results of the partitions:NumericString("123").aggregate(0)({ (sum, ch) => sum + ch.toInt }, { (p1, p2) => p1 + p2 })
- z
the initial value for the accumulated result of the partition - this will typically be the neutral element for the
seqopoperator (e.g.Nilfor list concatenation or0for summation) and may be evaluated more than once- seqop
an operator used to accumulate results within a partition
- combop
an associative operator used to combine results within a partition
- def apply(index: Int): Char
Return character at index
index.Return character at index
index.- returns
the character of this string at index
index, where0indicates the first element.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def canEqual(that: Any): Boolean
Method called from equality methods, so that user-defined subclasses can refuse to be equal to other collections of the same kind.
Method called from equality methods, so that user-defined subclasses can refuse to be equal to other collections of the same kind.
- that
the object with which this
NumericStringshould be compared- returns
trueif thisNumericStringcan possibly equalthat,falseotherwise. The test takes into consideration only the run-time types of objects but ignores their elements.
- def capitalize: String
Returns this string with first character converted to upper case (i.e.
Returns this string with first character converted to upper case (i.e. unchanged for a
NumericString).- returns
the string value of this
NumericString.
- def charAt(index: Int): Char
Returns the character at the zero-based
indexwithin theNumericString.Returns the character at the zero-based
indexwithin theNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- index
zero-based offset within
NumericString- returns
character found at
index
- def codePointAt(index: Int): Int
Returns the integer value of the Unicode code point at the zero-based
indexwithin theNumericString.Returns the integer value of the Unicode code point at the zero-based
indexwithin theNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- index
zero-based offset within
NumericString- returns
Unicode code point found at 'index'
- def codePointBefore(index: Int): Int
Returns the integer value of the Unicode code point immediately prior to the zero-based
indexwithin theNumericString.Returns the integer value of the Unicode code point immediately prior to the zero-based
indexwithin theNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- index
zero-based offset within
NumericString- returns
Unicode code point found immediately prior to 'index'
- def codePointCount(beginIndex: Int, endIndex: Int): Int
Returns the count of complete Unicode code points beginning at zero-based
beginIndexand ending at (but not including) zero-basedendIndex.Returns the count of complete Unicode code points beginning at zero-based
beginIndexand ending at (but not including) zero-basedendIndex.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- beginIndex
zero-based starting offset within
NumericString- endIndex
zero-based ending offset within
NumericString, one-past character range of interest- returns
count of complete Unicode code points found from BeginIndex, up to endIndex
- def collect(pf: PartialFunction[Char, Char]): String
Builds a new collection by applying a partial function to all characters of this
NumericStringon which the function is defined.Builds a new collection by applying a partial function to all characters of this
NumericStringon which the function is defined.- pf
the partial function which filters and maps the elements.
- returns
a new String resulting from applying the partial function
pfto each element on which it is defined and collecting the results. The order of the elements is preserved.
- def collectFirst[B](pf: PartialFunction[Char, B]): Option[B]
Finds the first character of the
NumericStringfor which the given partial function is defined, and applies the partial function to it.Finds the first character of the
NumericStringfor which the given partial function is defined, and applies the partial function to it.- pf
the partial function
- returns
an option value containing pf applied to the first value for which it is defined, or
Noneif none exists.
- def combinations(n: Int): Iterator[String]
Iterates over combinations.
Iterates over combinations. A _combination_ of length
nis a subsequence of the original sequence, with the elements taken in order. Thus,"xy"and"yy"are both length-2 combinations of"xyy", but"yx"is not. If there is more than one way to generate the same subsequence, only one will be returned.For example,
"xyyy"has three different ways to generate"xy"depending on whether the first, second, or third"y"is selected. However, since all are identical, only one will be chosen. Which of the three will be taken is an implementation detail that is not defined.- returns
An Iterator which traverses the possible n-element combinations of this
NumericString.
NumericString("12223").combinations(2) = Iterator(12, 13, 22, 23)
Example: - def compare(that: String): Int
Result of comparing
thiswith operandthat.Result of comparing
thiswith operandthat.Implement this method to determine how instances of A will be sorted.
Returns
xwhere:x < 0whenthis < thatx == 0whenthis == thatx > 0whenthis > that
- def compareTo(anotherString: String): Int
Compares the
NumericStringtoanotherString, returning an integer <0 ifNumericStringis less than the supplied string, 0 if identical, and >0 ifNumericStringis greater than the supplied string.Compares the
NumericStringtoanotherString, returning an integer <0 ifNumericStringis less than the supplied string, 0 if identical, and >0 ifNumericStringis greater than the supplied string.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- anotherString
other string we compare
NumericStringagainst- returns
integer <0, 0 or >0 corresponding to lexicographic ordering of
NumericStringvs.anotherString
- def concat(str: String): String
Concatenates supplied string
stronto the tail end of theNumericStringand returns the resulting String.Concatenates supplied string
stronto the tail end of theNumericStringand returns the resulting String.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- str
additional string to concatenate onto
NumericString- returns
string resulting from the concatenation
- def concatNumericString(that: NumericString): NumericString
Returns a new
NumericStringconcatenating thisNumericStringwith the passedNumericString.Returns a new
NumericStringconcatenating thisNumericStringwith the passedNumericString.- that
the
NumericStringto append- returns
a new
NumericStringthat concatenates thisNumericStringwiththat.
- def contains(s: CharSequence): Boolean
Tests whether this
NumericStringcontains a given value as an element.Tests whether this
NumericStringcontains a given value as an element.- s
the element to test.
- returns
trueif thisNumericStringhas an element that is equal (as determined by==) toelem,falseotherwise.
- def containsSlice[B](that: GenSeq[B]): Boolean
Tests whether this
NumericStringcontains a given sequence as a slice.Tests whether this
NumericStringcontains a given sequence as a slice.- that
the sequence to test
- returns
trueif thisNumericStringcontains a slice with the same elements asthat, otherwisefalse.
- def contentEquals(cs: CharSequence): Boolean
Returns
trueif theNumericStringcontent is the same as the supplied character sequencecs, otherwise returnsfalse.Returns
trueif theNumericStringcontent is the same as the supplied character sequencecs, otherwise returnsfalse.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- cs
character sequence for comparison
- returns
trueifNumericStringcontent is the same ascsfalseotherwise.
- def copyToArray(xs: Array[Char], start: Int): Unit
Copies the elements of this
NumericStringto an array.Copies the elements of this
NumericStringto an array. Fills the given arrayxswith values of thisNumericString, beginning at indexstart. Copying will stop once either the end of the currentNumericStringis reached, or the end of the target array is reached.- xs
the array to fill.
- start
the starting index.
- def copyToArray(xs: Array[Char]): Unit
Copies the elements of this
NumericStringto an array.Copies the elements of this
NumericStringto an array. Fills the given arrayxswith values of thisNumericStringCopying will stop once either the end of the currentNumericStringis reached, or the end of the target array is reached.- xs
the array to fill.
- def copyToArray(xs: Array[Char], start: Int, len: Int): Unit
Copies the elements of this
NumericStringto an array.Copies the elements of this
NumericStringto an array. Fills the given arrayxswith at mostlenelements of thisNumericString, starting at positionstart. Copying will stop once either the end of the currentNumericStringis reached, or the end of the target array is reached, orlenelements have been copied.- xs
the array to fill.
- start
the starting index.
- len
the maximal number of elements to copy.
- def copyToBuffer[B >: Char](dest: Buffer[B]): Unit
Copies all elements of this
NumericStringto a buffer.Copies all elements of this
NumericStringto a buffer.- dest
The buffer to which elements are copied.
- def corresponds[B](that: GenSeq[B])(p: (Char, B) => Boolean): Boolean
Tests whether every element of this
NumericStringrelates to the corresponding element of another sequence by satisfying a test predicate.Tests whether every element of this
NumericStringrelates to the corresponding element of another sequence by satisfying a test predicate.- B
the type of the elements of
that- that
the other sequence
- p
the test predicate, which relates elements from both sequences
- returns
trueif both sequences have the same length andp(x, y)istruefor all corresponding elementsxof thisNumericStringandyofthat, otherwisefalse.
- def count(p: (Char) => Boolean): Int
Counts the number of elements in the
NumericStringwhich satisfy a predicate.Counts the number of elements in the
NumericStringwhich satisfy a predicate.- p
the predicate used to test elements.
- returns
the number of elements satisfying the predicate
p.
- def diff(that: Seq[Char]): String
Computes the multiset difference between this
NumericStringand another sequence.Computes the multiset difference between this
NumericStringand another sequence.- that
the sequence of elements to remove
- returns
a new string which contains all elements of this
NumericStringexcept some occurrences of elements that also appear inthat. If an element valuexappears n times inthat, then the first n occurrences ofxwill not form part of the result, but any following occurrences will.
- def distinct: String
Builds a new
NumericStringfrom thisNumericStringwithout any duplicate elements.Builds a new
NumericStringfrom thisNumericStringwithout any duplicate elements.- returns
A new string which contains the first occurrence of every character of this
NumericString.
- def drop(n: Int): String
Selects all elements except first n ones.
Selects all elements except first n ones.
- n
the number of elements to drop from this
NumericString.- returns
a string consisting of all elements of this
NumericStringexcept the firstnones, or else the empty string if thisNumericStringhas less thannelements.
- def dropRight(n: Int): String
Selects all elements except last n ones.
Selects all elements except last n ones.
- n
The number of elements to take
- returns
a string consisting of all elements of this
NumericStringexcept the lastnones, or else the empty string, if thisNumericStringhas less thannelements.
- def dropWhile(p: (Char) => Boolean): String
Drops longest prefix of elements that satisfy a predicate.
Drops longest prefix of elements that satisfy a predicate.
- p
The predicate used to test elements.
- returns
the longest suffix of this
NumericStringwhose first element does not satisfy the predicatep.
- def endsWith[B](that: GenSeq[B]): Boolean
Tests whether this
NumericStringends with the given sequence.Tests whether this
NumericStringends with the given sequence.- that
the sequence to test
- returns
trueif thisNumericStringhasthatas a suffix,falseotherwise.
- def endsWith(suffix: String): Boolean
Returns
trueif theNumericStringcontent completely matches the suppliedsuffix, when both strings are aligned at their endpoints.Returns
trueif theNumericStringcontent completely matches the suppliedsuffix, when both strings are aligned at their endpoints.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- suffix
string for comparison as a suffix
- returns
trueifNumericStringcontent completely matches the suppliedsuffixfalseotherwise.
- def ensuringValid(f: (String) => String): NumericString
Applies the passed
String => Stringfunction to the underlyingStringvalue, and if the result is a numeric string, returns the result wrapped in aNumericString, else throwsAssertionError.Applies the passed
String => Stringfunction to the underlyingStringvalue, and if the result is a numeric string, returns the result wrapped in aNumericString, else throwsAssertionError.A factory/assertion method that produces a
NumericStringgiven a validStringvalue, or throwsAssertionError, if given an invalidStringvalue.Note: you should use this method only when you are convinced that it will always succeed, i.e., never throw an exception. It is good practice to add a comment near the invocation of this method indicating why you think it will always succeed to document your reasoning. If you are not sure an
ensuringValidcall will always succeed, you should use one of the other factory or validation methods provided on this object instead:isValid,tryingValid,passOrElse,goodOrElse, orrightOrElse.This method will inspect the result of applying the given function to this
NumericString's underlyingStringvalue and if the result is a valid numeric string, it will return aNumericStringrepresenting that value. Otherwise, theStringvalue returned by the given function is not a valid numeric string, so this method will throwAssertionError.This method differs from a vanilla
assertorensuringcall in that you get something you didn't already have if the assertion succeeds: a type that promises aStringcontains only numeric digit characters. With this method, you are asserting that you are convinced the result of the computation represented by applying the given function to thisNumericString's value will produce a valid numeric string. Instead of producing an invalidNumericString, this method will signal an invalid result with a loudAssertionError.- f
the
String => Stringfunction to apply to thisNumericString's underlyingStringvalue.- returns
the result of applying this
NumericString's underlyingStringvalue to to the passed function, wrapped in aNumericStringif it is a valid numeric string (else throwsAssertionError).
- Exceptions thrown
AssertionErrorif the result of applying thisNumericString's underlyingStringvalue to to the passed function contains non-digit characters.
- def equalsIgnoreCase(arg0: String): Boolean
Returns
trueif the suppliedarg0string is considered equal to thisNumericString.Returns
trueif the suppliedarg0string is considered equal to thisNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- arg0
string for comparison
- returns
trueifNumericStringcontent is the same asarg0falseotherwise.
- def exists(p: (Char) => Boolean): Boolean
Tests whether a predicate holds for at least one element of this
NumericString.Tests whether a predicate holds for at least one element of this
NumericString.- p
the predicate used to test elements.
- returns
trueif the given predicatepis satisfied by at least one character of thisNumericString, otherwisefalse
- def filter(p: (Char) => Boolean): String
Selects all elements of this
NumericStringwhich satisfy a predicate.Selects all elements of this
NumericStringwhich satisfy a predicate.- p
the predicate used to test elements.
- returns
a string consisting of all characters of this
NumericStringthat satisfy the given predicatep. Their order may not be preserved.
- def filterNot(p: (Char) => Boolean): String
Selects all elements of this
NumericStringwhich do not satisfy a predicate.Selects all elements of this
NumericStringwhich do not satisfy a predicate.- returns
a string consisting of all characters of this
NumericStringthat do not satisfy the given predicatep. Their order may not be preserved.
- def find(p: (Char) => Boolean): Option[Char]
Finds the first element of the
NumericStringsatisfying a predicate, if any.Finds the first element of the
NumericStringsatisfying a predicate, if any.- p
the predicate used to test elements.
- returns
an option value containing the first character of the
NumericStringthat satisfiesp, orNoneif none exists.
- def flatMap[B](f: (Char) => IterableOnce[B]): IndexedSeq[B]
Builds a new collection by applying a function to all elements of this
NumericStringand using the elements of the resulting collections.Builds a new collection by applying a function to all elements of this
NumericStringand using the elements of the resulting collections.- B
the element type of the returned collection.
- f
the function to apply to each element.
- returns
a new string resulting from applying the given collection-valued function
fto each element of thisNumericStringand concatenating the results.
- def fold[A1 >: Char](z: A1)(op: (A1, A1) => A1): A1
Folds the elements of this
NumericStringusing the specified associative binary operator.Folds the elements of this
NumericStringusing the specified associative binary operator.- A1
a type parameter for the binary operator, a supertype of
A.- z
a neutral element for the fold operation; may be added to the result an arbitrary number of times, and must not change the result (e.g.,
Nilfor list concatenation, 0 for addition, or 1 for multiplication).- op
a binary operator that must be associative.
- returns
the result of applying the fold operator
opbetween all the elements andz, orzif thisNumericStringis empty.
- def foldLeft[B](z: B)(op: (B, Char) => B): B
Applies a binary operator to a start value and all elements of this
NumericString, going left to right.Applies a binary operator to a start value and all elements of this
NumericString, going left to right.- B
the result type of the binary operator.
- z
the start value.
- op
the binary operator.
- returns
the result of inserting
opbetween consecutive elements of thisNumericString, going left to right with the start valuezon the left:op(...op(z, x_1), x_2, ..., x_n)
where
x1, ..., xnare the elements of thisNumericString. Returnszif thisNumericStringis empty.
- def foldRight[B](z: B)(op: (Char, B) => B): B
Applies a binary operator to all elements of this
NumericStringand a start value, going right to left.Applies a binary operator to all elements of this
NumericStringand a start value, going right to left.- B
the result type of the binary operator.
- z
the start value.
- op
the binary operator.
- returns
the result of inserting
opbetween consecutive elements of thisNumericString, going right to left with the start valuezon the right:op(x_1, op(x_2, ... op(x_n, z)...))
where
x1, ..., xnare the elements of thisNumericString. Returnszif thisNumericStringis empty.
- def forall(p: (Char) => Boolean): Boolean
Tests whether a predicate holds for all elements of this
NumericString.Tests whether a predicate holds for all elements of this
NumericString.- p
the predicate used to test elements.
- returns
trueif thisNumericStringis empty or the given predicatepholds for all elements of thisNumericString, otherwisefalse.
- def foreach(f: (Char) => Unit): Unit
Applies a function
fto all elements of thisNumericString.Applies a function
fto all elements of thisNumericString.- f
the function that is applied for its side-effect to every element. The result of function
fis discarded.
- def getBytes(charsetName: String): Array[Byte]
Returns an array of bytes corresponding to the
NumericStringcharacters, interpreted via the namedcharsetNameCharset-mapping of Unicode code points.Returns an array of bytes corresponding to the
NumericStringcharacters, interpreted via the namedcharsetNameCharset-mapping of Unicode code points.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- charsetName
string that names an already-known mapping of Unicode code points to bytes
- returns
array of bytes corresponding to
NumericStringcharacters
- def getBytes(charset: Charset): Array[Byte]
Returns an array of bytes corresponding to the
NumericStringcharacters, interpreted via the suppliedcharsetmapping of Unicode code points.Returns an array of bytes corresponding to the
NumericStringcharacters, interpreted via the suppliedcharsetmapping of Unicode code points.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- charset
a mapping of Unicode code points to bytes
- returns
array of bytes corresponding to
NumericStringcharacters
- def getBytes: Array[Byte]
Returns an array of bytes corresponding to the
NumericStringcharacters, interpreted via the platform's default Charset-mapping of Unicode code points.Returns an array of bytes corresponding to the
NumericStringcharacters, interpreted via the platform's default Charset-mapping of Unicode code points.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- returns
array of bytes corresponding to
NumericStringcharacters
- def getChars(srcBegin: Int, srcEnd: Int, dst: Array[Char], dstBegin: Int): Unit
Extracts the range of
NumericStringcharacters beginning at zero-basedsrcBeginthrough but not includingsrcEnd, into the supplied character arraydst, writing the characters at the zero-baseddstBeginindex forward within that array.Extracts the range of
NumericStringcharacters beginning at zero-basedsrcBeginthrough but not includingsrcEnd, into the supplied character arraydst, writing the characters at the zero-baseddstBeginindex forward within that array.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- srcBegin
zero-based index where to begin extracting characters from
NumericString- srcEnd
zero-based limit before which to stop extracting characters from
NumericString- dst
supplied character array to write extracted characters into
- dstBegin
zero-based index within destination array at which to begin writing
- returns
Unit -- this function modifies the supplied
dstarray
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- def groupBy[K](f: (Char) => K): Map[K, String]
Partitions this
NumericStringinto a map of strings according to some discriminator function.Partitions this
NumericStringinto a map of strings according to some discriminator function.- K
the type of keys returned by the discriminator function.
- f
the discriminator function.
- returns
A map from keys to strings such that the following invariant holds:
(xs groupBy f)(k) = xs filter (x => f(x) == k)That is, every key
kis bound to a string of those elementsxfor whichf(x)equalsk.
- def grouped(size: Int): Iterator[String]
Partitions elements in fixed size strings.
Partitions elements in fixed size strings.
- size
the number of elements per group
- returns
An iterator producing strings of size
size, except the last will be less than sizesizeif the elements don't divide evenly.
- See also
scala.collection.Iterator, method
grouped
- def hasDefiniteSize: Boolean
Tests whether this
NumericStringis known to have a finite size.Tests whether this
NumericStringis known to have a finite size. AlwaystrueforNumericString.- returns
trueif this collection is known to have finite size,falseotherwise.
- def head: Char
Selects the first element of this
NumericString.Selects the first element of this
NumericString.- returns
the first element of this
NumericString.
- Exceptions thrown
NoSuchElementExceptionif theNumericStringis empty.
- def headOption: Option[Char]
Optionally selects the first element.
Optionally selects the first element.
- returns
the first element of this
NumericStringif it is nonempty,Noneif it is empty.
- def indexOf(str: String, fromIndex: Int): Int
Returns zero-based index (in Unicode code units: logical index of characters) of starting-character position of first-encountered match of
strwithinNumericString, beginning search at zero-based indexfromIndex; returns -1 if no fully-matching substring is found, or iffromIndexis outside the bounds ofNumericString.Returns zero-based index (in Unicode code units: logical index of characters) of starting-character position of first-encountered match of
strwithinNumericString, beginning search at zero-based indexfromIndex; returns -1 if no fully-matching substring is found, or iffromIndexis outside the bounds ofNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- str
Unicode string to look for
- fromIndex
zero-based integer index at which to begin search for match of
strstring- returns
zero-based integer index in Unicode code units, of starting position of first-encountered instance of
strinNumericStringat/beyondfromIndex
- def indexOf(str: String): Int
Returns zero-based index (in Unicode code units: logical index of characters) of starting-character position of first-encountered match of
strwithinNumericString; returns -1 if no fully-matching substring is found.Returns zero-based index (in Unicode code units: logical index of characters) of starting-character position of first-encountered match of
strwithinNumericString; returns -1 if no fully-matching substring is found.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- str
Unicode string to look for
- returns
zero-based integer index in Unicode code units, of starting position of first-encountered instance of
strinNumericString
- def indexOf(ch: Int, fromIndex: Int): Int
Returns zero-based index (in Unicode code units: logical index of characters) of first-encountered
NumericStringcharacter matching supplied Unicodech, beginning search at zero-based indexfromIndex; returns -1 if no matching character is found or iffromIndexis outside the bounds ofNumericString.Returns zero-based index (in Unicode code units: logical index of characters) of first-encountered
NumericStringcharacter matching supplied Unicodech, beginning search at zero-based indexfromIndex; returns -1 if no matching character is found or iffromIndexis outside the bounds ofNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- ch
Unicode character to look for
- fromIndex
zero-based integer index at which to begin search for match of
chcharacter- returns
zero-based integer index in Unicode code units of first-encountered instance of
chat/beyondfromIndex
- def indexOf(ch: Int): Int
Returns zero-based index in Unicode code units (logical index of characters) of first-encountered
NumericStringcharacter matching the supplied Unicodech; returns -1 if no matching character is found.Returns zero-based index in Unicode code units (logical index of characters) of first-encountered
NumericStringcharacter matching the supplied Unicodech; returns -1 if no matching character is found.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- ch
Unicode character to look for
- returns
zero-based integer index in Unicode code units of first-encountered instance of
ch
- def indexOfSlice[B >: Char](that: GenSeq[B]): Int
Finds first index where this
NumericStringcontains a given sequence as a slice.Finds first index where this
NumericStringcontains a given sequence as a slice.- that
the sequence to test
- returns
the first index such that the elements of this
NumericStringstarting at this index match the elements of sequencethat, or-1of no such subsequence exists.
- def indexOfSlice[B >: Char](that: GenSeq[B], from: Int): Int
Finds first index after or at a start index where this
NumericStringcontains a given sequence as a slice.Finds first index after or at a start index where this
NumericStringcontains a given sequence as a slice.- that
the sequence to test
- from
the start index
- returns
the first index
>= fromsuch that the elements of thisNumericStringstarting at this index match the elements of sequencethat, or-1of no such subsequence exists.
- def indexWhere(p: (Char) => Boolean): Int
Finds index of first element satisfying some predicate.
Finds index of first element satisfying some predicate.
- p
the predicate used to test elements.
- returns
the index of the first element of this
NumericStringthat satisfies the predicatep, or-1, if none exists.
- def indexWhere(p: (Char) => Boolean, from: Int): Int
Finds index of the first element satisfying some predicate after or at some start index.
Finds index of the first element satisfying some predicate after or at some start index.
- p
the predicate used to test elements.
- from
the start index
- returns
the index
>= fromof the first element of thisNumericStringthat satisfies the predicatep, or-1, if none exists.
- def indices: Range
Produces the range of all indices of this sequence.
Produces the range of all indices of this sequence.
- returns
a
Rangevalue from0to one less than the length of thisNumericString.
- def init: String
Selects all elements except the last.
Selects all elements except the last.
- returns
a string consisting of all elements of this
NumericStringexcept the last one.
- Exceptions thrown
UnsupportedOperationExceptionif theNumericStringis empty.
- def inits: Iterator[String]
Iterates over the inits of this
NumericString.Iterates over the inits of this
NumericString. The first value will be the string for thisNumericStringand the final one will be an empty string, with the intervening values the results of successive applications ofinit.- returns
an iterator over all the inits of this
NumericString
NumericString("123").inits = Iterator(123, 12, 1, "")
Example: - def intern: String
Add this immutable
NumericString'sStringvalue to the pool of interned strings, so there is only one copy of the string's representation in memory, shared among all instances.Add this immutable
NumericString'sStringvalue to the pool of interned strings, so there is only one copy of the string's representation in memory, shared among all instances.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- returns
String which is now in the pool of interned strings
- def intersect(that: Seq[Char]): String
Computes the multiset intersection between this
NumericStringand another sequence.Computes the multiset intersection between this
NumericStringand another sequence.- that
the sequence of elements to intersect with.
- returns
a new string which contains all elements of this
NumericStringwhich also appear inthat. If an element valuexappears n times inthat, then the first n occurrences ofxwill be retained in the result, but any following occurrences will be omitted.
- def isDefinedAt(idx: Int): Boolean
Tests whether this
NumericStringcontains given index.Tests whether this
NumericStringcontains given index.- idx
the index to test
- returns
trueif thisNumericStringcontains an element at positionidx,falseotherwise.
- def isEmpty: Boolean
Returns
trueifNumericStringcontains no characters (not even whitespace); otherwise returnsfalse.Returns
trueifNumericStringcontains no characters (not even whitespace); otherwise returnsfalse.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- returns
trueifNumericStringcontains no characters (not even whitespace)falseotherwise.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterator: Iterator[Char]
Creates a new iterator over all elements contained in this iterable object.
Creates a new iterator over all elements contained in this iterable object.
- returns
the new iterator
- def last: Char
Selects the last element.
Selects the last element.
- returns
The last element of this
NumericString.
- Exceptions thrown
NoSuchElementExceptionIf theNumericStringis empty.
- def lastIndexOf(str: String, fromIndex: Int): Int
Returns zero-based index from the beginning of
NumericStringof the first character position for where the stringstrfully matched rightmost withinNumericString, with search beginning at zero-basedfromIndexand proceeding backwards.Returns zero-based index from the beginning of
NumericStringof the first character position for where the stringstrfully matched rightmost withinNumericString, with search beginning at zero-basedfromIndexand proceeding backwards.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- str
string for comparison
- fromIndex
zero-based index of starting position
- returns
zero-based integer index of first character position of where
strfully matched rightmost withinNumericString; -1 if not found
- def lastIndexOf(str: String): Int
Returns zero-based index from the beginning of
NumericStringof the first character position for where the stringstrfully matched rightmost withinNumericString.Returns zero-based index from the beginning of
NumericStringof the first character position for where the stringstrfully matched rightmost withinNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- str
string for comparison
- returns
zero-based integer index of first character position of where
strfully matched rightmost withinNumericString; -1 if not found
- def lastIndexOf(ch: Int, fromIndex: Int): Int
Returns zero-based index of the final occurrence of the Unicode character
chin theNumericString, with search beginning at zero-basedfromIndexand proceeding backwards.Returns zero-based index of the final occurrence of the Unicode character
chin theNumericString, with search beginning at zero-basedfromIndexand proceeding backwards.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- ch
Unicode character for which to search backwards
- fromIndex
zero-based index of starting position
- returns
zero-based index of the final (rightmost) occurrence of this character in
NumericString; -1 if not found
- def lastIndexOf(ch: Int): Int
Returns zero-based index of the final occurrence of the Unicode character
chin theNumericString.Returns zero-based index of the final occurrence of the Unicode character
chin theNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- ch
Unicode character for which to search backwards
- returns
zero-based integer index of the final occurrence of this character in
NumericString; -1 if not found
- def lastIndexOfSlice[B >: Char](that: GenSeq[B]): Int
Finds last index where this
NumericStringcontains a given sequence as a slice.Finds last index where this
NumericStringcontains a given sequence as a slice.- that
the sequence to test
- returns
the last index such that the elements of this
NumericStringstarting a this index match the elements of sequencethat, or-1of no such subsequence exists.
- def lastIndexOfSlice[B >: Char](that: GenSeq[B], end: Int): Int
Finds last index before or at a given end index where this
NumericStringcontains a given sequence as a slice.Finds last index before or at a given end index where this
NumericStringcontains a given sequence as a slice.- that
the sequence to test
- end
the end index
- returns
the last index
<= endsuch that the elements of thisNumericStringstarting at this index match the elements of sequencethat, or-1of no such subsequence exists.
- def lastIndexWhere(p: (Char) => Boolean): Int
Finds index of last element satisfying some predicate.
Finds index of last element satisfying some predicate.
- p
the predicate used to test elements.
- returns
the index of the last element of this
NumericStringthat satisfies the predicatep, or-1, if none exists.
- def lastIndexWhere(p: (Char) => Boolean, end: Int): Int
Finds index of last element satisfying some predicate before or at given end index.
Finds index of last element satisfying some predicate before or at given end index.
- p
the predicate used to test elements.
- returns
the index
<= endof the last element of thisNumericStringthat satisfies the predicatep, or-1, if none exists.
- def lastOption: Option[Char]
Optionally selects the last element.
Optionally selects the last element.
- returns
the last element of this
NumericStringif it is nonempty,Noneif it is empty.
- def length: Int
Returns length of this
NumericStringin Unicode characters.Returns length of this
NumericStringin Unicode characters.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- returns
length of this
NumericString
- def lengthCompare(len: Int): Int
Compares the length of this
NumericStringto a test value.Compares the length of this
NumericStringto a test value.- len
the test value that gets compared with the length.
- returns
A value
xwherex < 0 if this.length < len x == 0 if this.length == len x > 0 if this.length > len
The method as implemented here does not call
lengthdirectly; its running time isO(length min len)instead ofO(length). The method should be overwritten if computinglengthis cheap.
- def lines: Iterator[String]
Return all lines in this
NumericStringin an iterator.Return all lines in this
NumericStringin an iterator. Always returns a single string forNumericString. - def linesWithSeparators: Iterator[String]
Return all lines in this
NumericStringin an iterator, including trailing line end characters.Return all lines in this
NumericStringin an iterator, including trailing line end characters. Always returns a single string with no endline, forNumericString. - def map(f: (Char) => Char): String
Builds a new string by applying a function to all elements of this
NumericString.Builds a new string by applying a function to all elements of this
NumericString.- f
the function to apply to each element.
- returns
a new string resulting from applying the given function
fto each character of thisNumericStringand collecting the results.
- def matches(regex: String): Boolean
Returns
trueif the thisNumericString'sStringvalue matches the supplied regular expression,regex; otherwise returnsfalse.Returns
trueif the thisNumericString'sStringvalue matches the supplied regular expression,regex; otherwise returnsfalse.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- regex
regular-expression string
- returns
trueifNumericStringcontent matches supplied regular expressionregex;falseotherwise.
- def max: Char
Finds the largest element.
Finds the largest element.
- returns
the largest character of this
NumericString.
- def maxBy[B](f: (Char) => B)(implicit cmp: Ordering[B]): Char
Finds the first element which yields the largest value measured by function f.
Finds the first element which yields the largest value measured by function f.
- B
The result type of the function f.
- f
The measuring function.
- cmp
An ordering to be used for comparing elements.
- returns
the first element of this
NumericStringwith the largest value measured by function f with respect to the orderingcmp.
- def min: Char
Finds the smallest element.
Finds the smallest element.
- returns
the smallest element of this
NumericString.
- def minBy[B](f: (Char) => B)(implicit cmp: Ordering[B]): Char
Finds the first element which yields the smallest value measured by function f.
Finds the first element which yields the smallest value measured by function f.
- B
The result type of the function f.
- f
The measuring function.
- cmp
An ordering to be used for comparing elements.
- returns
the first element of this
NumericStringwith the smallest value measured by function f with respect to the orderingcmp.
- def mkString(start: String, sep: String, end: String): String
Displays all elements of this
NumericStringin a string using start, end, and separator strings.Displays all elements of this
NumericStringin a string using start, end, and separator strings.- start
the starting string.
- sep
the separator string.
- end
the ending string.
- returns
a string representation of this
NumericString. The resulting string begins with the stringstartand ends with the stringend. Inside, the string representations (w.r.t. the methodtoString) of all elements of thisNumericStringare separated by the stringsep.
NumericString("123").mkString("(", "; ", ")") = "(1; 2; 3)"
Example: - def mkString(sep: String): String
Displays all elements of this
NumericStringin a string using a separator string.Displays all elements of this
NumericStringin a string using a separator string.- sep
the separator string.
- returns
a string representation of this
NumericString. In the resulting string the string representations (w.r.t. the methodtoString) of all elements of thisNumericStringare separated by the stringsep.
NumericString("123").mkString("|") = "1|2|3"
Example: - def mkString: String
Displays all elements of this
NumericStringin a string.Displays all elements of this
NumericStringin a string.- returns
a string representation of this
NumericString. In the resulting string the string representations (w.r.t. the methodtoString) of all elements of thisNumericStringfollow each other without any separator string.
- def nonEmpty: Boolean
Tests whether the
NumericStringis not empty.Tests whether the
NumericStringis not empty.- returns
trueif theNumericStringcontains at least one element,falseotherwise.
- def offsetByCodePoints(index: Int, codePointOffset: Int): Int
Returns the "byte distance" required from start of string, to reach the position of the supplied byte
indexplus the number ofcodePointOffsetpoints further.Returns the "byte distance" required from start of string, to reach the position of the supplied byte
indexplus the number ofcodePointOffsetpoints further.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- index
byte index of start position in spacing computation
- codePointOffset
how many code points to advance (may be variable length per code point)
- returns
zero-based offset in bytes from start of
NumericString, to reach the designated position
- def padTo(len: Int, elem: Char): String
A string copy of this
NumericStringwith an element value appended until a given target length is reached.A string copy of this
NumericStringwith an element value appended until a given target length is reached.- len
the target length
- elem
the padding value
- returns
a new string consisting of all elements of this
NumericStringfollowed by the minimal number of occurrences ofelemso that the resulting string has a length of at leastlen.
- def partition(p: (Char) => Boolean): (String, String)
Partitions this
NumericStringin two strings according to a predicate.Partitions this
NumericStringin two strings according to a predicate.- returns
a pair of strings -- the first string consists of all elements that satisfy the predicate
pand the second string consists of all elements that don't. The relative order of the elements in the resulting strings may not be preserved.
- def patch(from: Int, that: GenSeq[Char], replaced: Int): String
Produces a new string where a slice of elements in this
NumericStringis replaced by another sequence.Produces a new string where a slice of elements in this
NumericStringis replaced by another sequence.- from
the index of the first replaced element
- replaced
the number of elements to drop in the original
NumericString- returns
a new string consisting of all elements of this
NumericStringexcept thatreplacedelements starting fromfromare replaced bypatch.
- def permutations: Iterator[String]
Iterates over distinct permutations.
Iterates over distinct permutations.
- returns
An Iterator which traverses the distinct permutations of this
NumericString.
NumericString("122").permutations = Iterator(122, 212, 221)
Example: - def prefixLength(p: (Char) => Boolean): Int
Returns the length of the longest prefix whose elements all satisfy some predicate.
Returns the length of the longest prefix whose elements all satisfy some predicate.
- p
the predicate used to test elements.
- returns
the length of the longest prefix of this
NumericStringsuch that every element of the segment satisfies the predicatep.
- def product[B >: Char](implicit num: Numeric[B]): B
Multiplies up the elements of this collection.
Multiplies up the elements of this collection.
- B
the result type of the
*operator.- num
an implicit parameter defining a set of numeric operations which includes the
*operator to be used in forming the product.- returns
the product of all elements of this
NumericStringwith respect to the*operator innum.
- def r: Regex
You can follow a
NumericStringwith.r, turning it into aRegex.You can follow a
NumericStringwith.r, turning it into aRegex.This is not particularly useful for a
NumericString, given the limitations on its content. - def r(groupNames: String*): Regex
You can follow a
NumericStringwith.r(g1, ... , gn), turning it into aRegex, with group names g1 through gn.You can follow a
NumericStringwith.r(g1, ... , gn), turning it into aRegex, with group names g1 through gn.This is not particularly useful for a
NumericString, given the limitations on its content.- groupNames
The names of the groups in the pattern, in the order they appear.
- def reduce[A1 >: Char](op: (A1, A1) => A1): A1
Reduces the elements of this
NumericStringusing the specified associative binary operator.Reduces the elements of this
NumericStringusing the specified associative binary operator.- A1
A type parameter for the binary operator, a supertype of
A.- op
A binary operator that must be associative.
- returns
The result of applying reduce operator
opbetween all the elements if theNumericStringis nonempty.
- Exceptions thrown
UnsupportedOperationExceptionif thisNumericStringis empty.
- def reduceLeft[B >: Char](op: (B, Char) => B): B
Applies a binary operator to all elements of this
NumericString, going left to right.Applies a binary operator to all elements of this
NumericString, going left to right.- B
the result type of the binary operator.
- op
the binary operator.
- returns
the result of inserting
opbetween consecutive elements of thisNumericString, going left to right:op( op( ... op(x_1, x_2) ..., x_{n-1}), x_n)where
x1, ..., xnare the elements of thisNumericString.
- Exceptions thrown
UnsupportedOperationExceptionif thisNumericStringis empty.
- def reduceLeftOption[B >: Char](op: (B, Char) => B): Option[B]
Optionally applies a binary operator to all elements of this
NumericString, going left to right.Optionally applies a binary operator to all elements of this
NumericString, going left to right.- B
the result type of the binary operator.
- op
the binary operator.
- returns
an option value containing the result of
reduceLeft(op)if thisNumericStringis nonempty,Noneotherwise.
- def reduceOption[A1 >: Char](op: (A1, A1) => A1): Option[A1]
Reduces the elements of this
NumericString, if any, using the specified associative binary operator.Reduces the elements of this
NumericString, if any, using the specified associative binary operator.- A1
A type parameter for the binary operator, a supertype of
A.- op
A binary operator that must be associative.
- returns
An option value containing result of applying reduce operator
opbetween all the elements if the collection is nonempty, andNoneotherwise.
- def reduceRight[B >: Char](op: (Char, B) => B): B
Applies a binary operator to all elements of this
NumericString, going right to left.Applies a binary operator to all elements of this
NumericString, going right to left.- B
the result type of the binary operator.
- op
the binary operator.
- returns
the result of inserting
opbetween consecutive elements of thisNumericString, going right to left:op(x_1, op(x_2, ..., op(x_{n-1}, x_n)...))where
x1, ..., xnare the elements of thisNumericString.
- Exceptions thrown
UnsupportedOperationExceptionif thisNumericStringis empty.
- def reduceRightOption[B >: Char](op: (Char, B) => B): Option[B]
Optionally applies a binary operator to all elements of this
NumericString, going right to left.Optionally applies a binary operator to all elements of this
NumericString, going right to left.- B
the result type of the binary operator.
- op
the binary operator.
- returns
an option value containing the result of
reduceRight(op)if thisNumericStringis nonempty,Noneotherwise.
- def regionMatches(toffset: Int, other: String, ooffset: Int, len: Int): Boolean
Returns
trueif the given region of text matches completely for thelencharacters beginning attoffsetin theNumericStringtext and atooffsetin the suppliedotherstring text; otherwise returnsfalse.Returns
trueif the given region of text matches completely for thelencharacters beginning attoffsetin theNumericStringtext and atooffsetin the suppliedotherstring text; otherwise returnsfalse.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- toffset
zero-based offset of start point of comparison in
NumericStringtext- other
string supplied for comparison
- ooffset
zero-based offset of start point of comparison in
otherstring text- len
length of comparison, in characters
- returns
trueif region of text matches completely for given length;falseotherwise.
- def regionMatches(ignoreCase: Boolean, toffset: Int, other: String, ooffset: Int, len: Int): Boolean
Returns
trueif the given region of text matches completely for thelencharacters beginning attoffsetin theNumericStringtext and atooffsetin the suppliedotherstring text, with the option toignoreCaseduring matching; otherwise returnsfalse.Returns
trueif the given region of text matches completely for thelencharacters beginning attoffsetin theNumericStringtext and atooffsetin the suppliedotherstring text, with the option toignoreCaseduring matching; otherwise returnsfalse.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- ignoreCase
if nonzero, comparison ignores case
- toffset
zero-based offset of start point of comparison in
NumericStringtext- other
string supplied for comparison
- ooffset
zero-based offset of start point of comparison in
otherstring text- len
length of comparison, in characters
- returns
trueif region of text matches completely for given length;falseotherwise.
- def replace(target: CharSequence, replacement: CharSequence): String
Returns the new
Stringresulting from replacing all occurrences ofCharSequencetargetwithreplacement.Returns the new
Stringresulting from replacing all occurrences ofCharSequencetargetwithreplacement.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- target
character sequence to replace
- replacement
character sequence that will take its place
- returns
string resulting from zero or more replacement(s)
- def replace(oldChar: Char, newChar: Char): String
Returns the new
Stringresulting from replacing all occurrences ofoldCharwithnewChar.Returns the new
Stringresulting from replacing all occurrences ofoldCharwithnewChar.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- oldChar
character to replace
- newChar
character that will take its place
- returns
string resulting from zero or more replacement(s)
- def replaceAll(regex: String, replacement: String): String
Returns the new
Stringresulting from replacing allregexstring matches with thereplacementstring.Returns the new
Stringresulting from replacing allregexstring matches with thereplacementstring.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- regex
regular expression string
- replacement
string to replace in place of any regular expression matches in the original
NumericString- returns
string resulting from zero or more replacement(s)
- def replaceAllLiterally(literal: String, replacement: String): String
Replace all literal occurrences of
literalwith the stringreplacement.Replace all literal occurrences of
literalwith the stringreplacement. This is equivalent to java.lang.String#replaceAll except that both arguments are appropriately quoted to avoid being interpreted as metacharacters.- literal
the string which should be replaced everywhere it occurs
- replacement
the replacement string
- returns
the resulting string
- def replaceFirst(regex: String, replacement: String): String
Returns the new
Stringresulting from replacing the first-foundregexstring match with thereplacementstring.Returns the new
Stringresulting from replacing the first-foundregexstring match with thereplacementstring.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- regex
regular expression string
- replacement
string to replace in place of first regular expression match in the original
NumericString- returns
string resulting from zero or one replacement(s)
- def reverse: String
Returns new string with elements in reversed order.
Returns new string with elements in reversed order.
- returns
A new string with all elements of this
NumericStringin reversed order.
- def reverseIterator: Iterator[Char]
An iterator yielding elements in reversed order.
An iterator yielding elements in reversed order.
Note:
xs.reverseIteratoris the same asxs.reverse.iteratorbut might be more efficient.- returns
an iterator yielding the elements of this
NumericStringin reversed order
- def reverseMap[B](f: (Char) => B): IndexedSeq[B]
Builds a new collection by applying a function to all elements of this
NumericStringand collecting the results in reversed order.Builds a new collection by applying a function to all elements of this
NumericStringand collecting the results in reversed order.- B
the element type of the returned collection.
- f
the function to apply to each element.
- returns
a new collection resulting from applying the given function
fto each element of thisNumericStringand collecting the results in reversed order.
- def sameElements[B >: Char](that: GenIterable[B]): Boolean
Checks if the other iterable collection contains the same elements in the same order as this
NumericString.Checks if the other iterable collection contains the same elements in the same order as this
NumericString.- that
the collection to compare with.
- returns
true, if both collections contain the same elements in the same order,falseotherwise.
- def scan(z: Char)(op: (Char, Char) => Char): IndexedSeq[Char]
Computes a prefix scan of the elements of the collection.
Computes a prefix scan of the elements of the collection.
Note: The neutral element
zmay be applied more than once.- z
neutral element for the operator
op- op
the associative operator for the scan
- returns
a new string containing the prefix scan of the elements in this
NumericString
- def scanLeft(z: String)(op: (String, Char) => String): IndexedSeq[String]
Produces a collection containing cumulative results of applying the operator going left to right.
Produces a collection containing cumulative results of applying the operator going left to right.
- z
the initial value
- op
the binary operator applied to the intermediate result and the element
- returns
collection with intermediate results
- def scanRight(z: String)(op: (Char, String) => String): IndexedSeq[String]
Produces a collection containing cumulative results of applying the operator going right to left.
Produces a collection containing cumulative results of applying the operator going right to left. The head of the collection is the last cumulative result.
- z
the initial value
- op
the binary operator applied to the intermediate result and the element
- returns
collection with intermediate results
- def segmentLength(p: (Char) => Boolean, from: Int): Int
Computes length of longest segment whose elements all satisfy some predicate.
Computes length of longest segment whose elements all satisfy some predicate.
- p
the predicate used to test elements.
- from
the index where the search starts.
- returns
the length of the longest segment of this
NumericStringstarting from indexfromsuch that every element of the segment satisfies the predicatep.
- def seq: WrappedString
A version of this collection with all of the operations implemented sequentially (i.e., in a single-threaded manner).
A version of this collection with all of the operations implemented sequentially (i.e., in a single-threaded manner).
This method returns a reference to this collection. In parallel collections, it is redefined to return a sequential implementation of this collection. In both cases, it has O(1) complexity.
- returns
a sequential view of the collection.
- def size: Int
The size of this
NumericString.The size of this
NumericString.- returns
the number of elements in this
NumericString.
- def slice(from: Int, until: Int): String
Selects an interval of elements.
Selects an interval of elements. The returned collection is made up of all elements
xwhich satisfy the invariant:from <= indexOf(x) < until
- from
the lowest index to include from this
NumericString.- until
the lowest index to EXCLUDE from this
NumericString.- returns
a string containing the elements greater than or equal to index
fromextending up to (but not including) indexuntilof thisNumericString.
- def sliding(size: Int): Iterator[String]
Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped.) "Sliding window" step is 1 by default.
Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped.) "Sliding window" step is 1 by default.
- size
the number of elements per group
- returns
An iterator producing strings of size
size, except the last and the only element will be truncated if there are fewer elements than size.
- See also
scala.collection.Iterator, method
sliding
- def sliding(size: Int, step: Int): Iterator[String]
Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped.)
Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped.)
- size
the number of elements per group
- step
the distance between the first elements of successive groups
- returns
An iterator producing strings of size
size, except the last and the only element will be truncated if there are fewer elements than size.
- See also
scala.collection.Iterator, method
sliding
- def sortBy[B](f: (Char) => B)(implicit ord: Ordering[B]): String
Sorts this
NumericStringaccording to the Ordering which results from transforming an implicitly given Ordering with a transformation function.Sorts this
NumericStringaccording to the Ordering which results from transforming an implicitly given Ordering with a transformation function.- B
the target type of the transformation
f, and the type where the orderingordis defined.- f
the transformation function mapping elements to some other domain
B.- ord
the ordering assumed on domain
B.- returns
a string consisting of the elements of this
NumericStringsorted according to the ordering wherex < yiford.lt(f(x), f(y)).
NumericString("212").sortBy(_.toInt) res13: String = 122
- See also
scala.math.Ordering
Example: - def sortWith(lt: (Char, Char) => Boolean): String
Sorts this
NumericStringaccording to a comparison function.Sorts this
NumericStringaccording to a comparison function.The sort is stable. That is, elements that are equal (as determined by
lt) appear in the same order in the sorted sequence as in the original.- lt
the comparison function which tests whether its first argument precedes its second argument in the desired ordering.
- returns
a string consisting of the elements of this
NumericStringsorted according to the comparison functionlt.
NumericString("212").sortWith(_.compareTo(_) < 0) res14: String = 122
Example: - def sorted[B >: Char](implicit ord: Ordering[B]): String
Sorts this
NumericStringaccording to an Ordering.Sorts this
NumericStringaccording to an Ordering.The sort is stable. That is, elements that are equal (as determined by
lt) appear in the same order in the sorted sequence as in the original.- ord
the ordering to be used to compare elements.
- returns
a string consisting of the elements of this
NumericStringsorted according to the orderingord.
- See also
scala.math.Ordering
- def span(p: (Char) => Boolean): (String, String)
Splits this
NumericStringinto a prefix/suffix pair according to a predicate.Splits this
NumericStringinto a prefix/suffix pair according to a predicate.Note:
c span pis equivalent to (but possibly more efficient than)(c takeWhile p, c dropWhile p), provided the evaluation of the predicatepdoes not cause any side-effects.- p
the test predicate
- returns
a pair of strings consisting of the longest prefix of this
NumericStringwhose elements all satisfyp, and the rest of thisNumericString.
- def split(separator: Char): Array[String]
Split this
NumericStringaround the separator characterSplit this
NumericStringaround the separator characterIf this
NumericStringis the empty string, returns an array of strings that contains a single empty string.If this
NumericStringis not the empty string, returns an array containing the substrings terminated by the start of the string, the end of the string or the separator character, excluding empty trailing substringsThe behaviour follows, and is implemented in terms of String.split(re: String)
- separator
the character used as a delimiter
scala> NumericString("1234").split('3') res15: Array[String] = Array(12, 4) // //splitting the empty string always returns the array with a single //empty string scala> NumericString("").split('3') res16: Array[String] = Array("") // //only trailing empty substrings are removed scala> NumericString("1234").split('4') res17: Array[String] = Array(123) // scala> NumericString("1234").split('1') res18: Array[String] = Array("", 234) // scala> NumericString("12341").split('1') res19: Array[String] = Array("", 234) // scala> NumericString("11211").split('1') res20: Array[String] = Array("", "", 2) // //all parts are empty and trailing scala> NumericString("1").split('1') res21: Array[String] = Array() // scala> NumericString("11").split('1') res22: Array[String] = Array()
Example: - def split(separators: Array[Char]): Array[String]
Returns an array of Strings resulting from splitting this
NumericStringat all points where one of theseparatorscharacters is encountered.Returns an array of Strings resulting from splitting this
NumericStringat all points where one of theseparatorscharacters is encountered.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- separators
array of characters, any of which are valid split triggers
- returns
array of strings, after splitting
NumericStringat all points where one of theseparatorscharacters is encountered
- def split(regex: String, limit: Int): Array[String]
Returns an array of strings produced by splitting
NumericStringat up tolimitlocations matching the suppliedregex; theregex-matching characters are omitted from the output.Returns an array of strings produced by splitting
NumericStringat up tolimitlocations matching the suppliedregex; theregex-matching characters are omitted from the output.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- regex
string for pattern matching
- limit
maximum number of split output strings that will be generated by this function; further potential splits get ignored
- returns
array of strings produced by splitting
NumericStringat every location matching suppliedregex, up tolimitoccurrences
- def split(regex: String): Array[String]
Returns an array of strings produced by splitting
NumericStringat every location matching the suppliedregex; theregex-matching characters are omitted from the output.Returns an array of strings produced by splitting
NumericStringat every location matching the suppliedregex; theregex-matching characters are omitted from the output.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- regex
string for pattern matching
- returns
array of strings produced by splitting
NumericStringat every location matching suppliedregex
- def splitAt(n: Int): (String, String)
Splits this
NumericStringinto two at a given position.Splits this
NumericStringinto two at a given position. Note:c splitAt nis equivalent to (but possibly more efficient than)(c take n, c drop n).- n
the position at which to split.
- returns
a pair of strings consisting of the first
nelements of thisNumericString, and the other elements.
- def startsWith(prefix: String, toffset: Int): Boolean
Returns
trueif theNumericStringcontent completely matches the suppliedprefix, starting attoffsetcharacters in theNumericString.Returns
trueif theNumericStringcontent completely matches the suppliedprefix, starting attoffsetcharacters in theNumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- prefix
string for comparison as prefix
- toffset
zero-based integer start point for comparison within the
NumericString- returns
trueifNumericStringcontent is the same asprefixfor the entire length ofprefixshifted over,falseotherwise.
- def startsWith(prefix: String): Boolean
Returns
trueif theNumericStringcontent completely matches the suppliedprefix, when both strings are aligned at their startpoints up to the length ofprefix.Returns
trueif theNumericStringcontent completely matches the suppliedprefix, when both strings are aligned at their startpoints up to the length ofprefix.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- prefix
string for comparison as prefix
- returns
trueifNumericStringcontent is the same asprefixfor the entire length ofprefixfalseotherwise.
- def stringPrefix: String
Defines the prefix of this object's
toStringrepresentation.Defines the prefix of this object's
toStringrepresentation.- returns
a string representation which starts the result of
toStringapplied to thisNumericString. By default the string prefix is the simple name of the collection classNumericString.
- def stripLineEnd: String
Strip trailing line end character from this string if it has one.
Strip trailing line end character from this string if it has one.
A line end character is one of
LF- line feed (0x0Ahex)FF- form feed (0x0Chex)
If a line feed character
LFis preceded by a carriage returnCR(0x0Dhex), theCRcharacter is also stripped (Windows convention). - def stripMargin(marginChar: Char): String
Strip a leading prefix consisting of blanks or control characters followed by
marginCharfrom the line. - def stripMargin: String
Strip a leading prefix consisting of blanks or control characters followed by
|from the line. - def stripPrefix(prefix: String): String
Returns this
NumericStringas a string with the givenprefixstripped.Returns this
NumericStringas a string with the givenprefixstripped. If thisNumericStringdoes not start withprefix, it is returned unchanged. - def stripSuffix(suffix: String): String
Returns this
NumericStringas a string with the givensuffixstripped.Returns this
NumericStringas a string with the givensuffixstripped. If thisNumericStringdoes not end withsuffix, it is returned unchanged. - def subSequence(beginIndex: Int, endIndex: Int): CharSequence
Returns the character sequence extracted from
NumericStringbeginning at zero-based offsetbeginIndexand continuing until (but not including) offsetendIndex.Returns the character sequence extracted from
NumericStringbeginning at zero-based offsetbeginIndexand continuing until (but not including) offsetendIndex.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- beginIndex
zero-based integer offset at which character extraction begins
- endIndex
zero-based integer offset before which character extraction ends
- returns
CharSequence of zero or more extracted characters
- def substring(beginIndex: Int, endIndex: Int): String
Returns a string extracted
NumericStringstarting from the zero-basedbeginIndexthrough but not including the zero-basedendIndexoffset.Returns a string extracted
NumericStringstarting from the zero-basedbeginIndexthrough but not including the zero-basedendIndexoffset.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- beginIndex
zero-based integer offset at which substring extraction begins
- endIndex
zero-based integer offset before which substring extraction ends
- returns
returns string extracted from
NumericString
- def substring(beginIndex: Int): String
Returns a string extracted from
NumericStringfrom the zero-basedbeginIndexthrough the end of the string.Returns a string extracted from
NumericStringfrom the zero-basedbeginIndexthrough the end of the string.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- beginIndex
zero-based integer offset at which substring extraction begins (continues through end of
NumericIndexstring)- returns
returns string extracted from
NumericString
- def sum[B >: Char](implicit num: Numeric[B]): B
Sums up the elements of this collection.
Sums up the elements of this collection.
- returns
the sum of all character values in this
NumericString
- def tail: String
Selects all elements except the first.
Selects all elements except the first.
- returns
a string consisting of all elements of this
NumericStringexcept the first one.
- Exceptions thrown
UnsupportedOperationExceptionif theNumericStringis empty.
- def tails: Iterator[String]
Iterates over the tails of this
NumericString.Iterates over the tails of this
NumericString. The first value will be thisNumericStringas a string and the final one will be an empty string, with the intervening values the results of successive applications oftail.- returns
an iterator over all the tails of this
NumericString
scala> NumericString("123").tails.toList res31: List[String] = List(123, 23, 3, "")
Example: - def take(n: Int): String
Selects first n elements.
Selects first n elements.
- n
the number of elements to take from this
NumericString.- returns
a string consisting only of the first
nelements of thisNumericString, or else the wholeNumericString, if it has less thannelements.
- def takeRight(n: Int): String
Selects last n elements.
Selects last n elements.
- n
the number of elements to take
- returns
a string consisting only of the last
nelements of thisNumericString, or else the wholeNumericString, if it has less thannelements.
- def takeWhile(p: (Char) => Boolean): String
Takes longest prefix of elements that satisfy a predicate.
Takes longest prefix of elements that satisfy a predicate.
- p
The predicate used to test elements.
- returns
the longest prefix of this
NumericStringwhose elements all satisfy the predicatep.
- def toArray: Array[Char]
Converts this
NumericStringto an array.Converts this
NumericStringto an array.- returns
an array containing all elements of this
NumericString.
- def toBuffer[A1 >: Char]: Buffer[A1]
Uses the contents of this
NumericStringto create a new mutable buffer.Uses the contents of this
NumericStringto create a new mutable buffer.- returns
a buffer containing all elements of this
NumericString.
- def toByte: Byte
Parse as a
ByteParse as a
Byte- Exceptions thrown
java.lang.NumberFormatExceptionIf the string does not contain a parsableByte.
- def toCharArray: Array[Char]
Returns an array of Unicode characters corresponding to the
NumericString.Returns an array of Unicode characters corresponding to the
NumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- returns
array of Unicode characters corresponding to the
NumericString
- def toDouble: Double
Parse as a
Double.Parse as a
Double.- Exceptions thrown
java.lang.NumberFormatExceptionIf the string does not contain a parsableDouble.
- def toFloat: Float
Parse as a
Float.Parse as a
Float.- Exceptions thrown
java.lang.NumberFormatExceptionIf the string does not contain a parsableFloat.
- def toIndexedSeq: IndexedSeq[Char]
Converts this
NumericStringto an indexed sequence.Converts this
NumericStringto an indexed sequence.- returns
an indexed sequence containing all elements of this
NumericString.
- def toInt: Int
Parse as an
IntParse as an
Int- Exceptions thrown
java.lang.NumberFormatExceptionIf the string does not contain a parsableInt.
- def toIterable: Iterable[Char]
Converts this
NumericStringto an iterable collection.Converts this
NumericStringto an iterable collection.- returns
an
Iterablecontaining all elements of thisNumericString.
- def toIterator: Iterator[Char]
Returns an Iterator over the elements in this
NumericString.Returns an Iterator over the elements in this
NumericString.- returns
an Iterator containing all elements of this
NumericString.
- def toList: List[Char]
Converts this
NumericStringto a list.Converts this
NumericStringto a list.- returns
a list containing all elements of this
NumericString.
- def toLong: Long
Parse as a
Long.Parse as a
Long.- Exceptions thrown
java.lang.NumberFormatExceptionIf the string does not contain a parsableLong.
- def toSeq: Seq[Char]
Converts this
NumericStringto a sequence.Converts this
NumericStringto a sequence.- returns
a sequence containing all elements of this
NumericString.
- def toSet[B >: Char]: Set[B]
Converts this
NumericStringto a set.Converts this
NumericStringto a set.- returns
a set containing all elements of this
NumericString.
- def toShort: Short
Parse as a
Short.Parse as a
Short.- Exceptions thrown
java.lang.NumberFormatExceptionIf the string does not contain a parsableShort.
- def toStream: Stream[Char]
Converts this
NumericStringto a stream.Converts this
NumericStringto a stream.- returns
a stream containing all elements of this
NumericString.
- def toString(): String
A string representation of this
NumericString.A string representation of this
NumericString.- Definition Classes
- NumericString → Any
- def toVector: Vector[Char]
Converts this
NumericStringto a Vector.Converts this
NumericStringto a Vector.- returns
a vector containing all elements of this
NumericString.
- def trim: String
Return new string resulting from removing any whitespace characters from the start and end of the
NumericString.Return new string resulting from removing any whitespace characters from the start and end of the
NumericString.For more detail, see the documentation for the corresponding method in the Javadoc documentation for java.lang.String.
- returns
string resulting from removing any whitespace characters from start and end of original string
- def union(that: Seq[Char]): IndexedSeq[Char]
Produces a new sequence which contains all elements of this
NumericStringand also all elements of a given sequence.Produces a new sequence which contains all elements of this
NumericStringand also all elements of a given sequence.xs union ysis equivalent toxs ++ ys.Another way to express this is that
xs union yscomputes the order-preserving multi-set union ofxsandys.unionis hence a counter-part ofdiffandintersectwhich also work on multi-sets.- returns
a new string which contains all elements of this
NumericStringfollowed by all elements ofthat.
- def updated(index: Int, elem: NumericChar): NumericString
A copy of this
NumericStringwith one single replaced element.A copy of this
NumericStringwith one single replaced element.- index
the position of the replacement
- elem
the replacing element
- returns
a string copy of this
NumericStringwith the element at positionindexreplaced byelem.
- Exceptions thrown
IndexOutOfBoundsExceptionifindexdoes not satisfy0 <= index < length.
- val value: String
- def view: StringView
Creates a non-strict view of this
NumericString.Creates a non-strict view of this
NumericString.- returns
a non-strict view of this
NumericString.
- def withFilter(p: (Char) => Boolean): WithFilter
Creates a non-strict filter of this
NumericString.Creates a non-strict filter of this
NumericString.Note: the difference between
c filter pandc withFilter pis that the former creates a new collection, whereas the latter only restricts the domain of subsequentmap,flatMap,foreach, andwithFilteroperations.- p
the predicate used to test elements.
- returns
an object of class
WithFilter, which supportsmap,flatMap,foreach, andwithFilteroperations. All these operations apply to those elements of thisNumericStringwhich satisfy the predicatep.
- def zip[B](that: Iterable[B]): Iterable[(Char, B)]
Returns a
Iterableof pairs formed from thisNumericStringand another iterable collection by combining corresponding elements in pairs.Returns a
Iterableof pairs formed from thisNumericStringand another iterable collection by combining corresponding elements in pairs. If one of the two collections is longer than the other, its remaining elements are ignored.- B
the type of the second half of the returned pairs
- that
The iterable providing the second half of each result pair
- returns
a collection containing pairs consisting of corresponding elements of this
NumericStringandthat. The length of the returned collection is the minimum of the lengths of thisNumericStringandthat.
- def zipAll[A1 >: Char, B](that: Iterable[B], thisElem: A1, thatElem: B): Iterable[(A1, B)]
Returns a collection of pairs formed from this
NumericStringand another iterable collection by combining corresponding elements in pairs.Returns a collection of pairs formed from this
NumericStringand another iterable collection by combining corresponding elements in pairs. If one of the two collections is shorter than the other, placeholder elements are used to extend the shorter collection to the length of the longer.- B
the type of the second half of the returned pairs
- that
the iterable providing the second half of each result pair
- thisElem
the element to be used to fill up the result if this
NumericStringis shorter thanthat.- thatElem
the element to be used to fill up the result if
thatis shorter than thisNumericString.- returns
a new
Iterableconsisting of corresponding elements of thisNumericStringandthat. The length of the returned collection is the maximum of the lengths of thisNumericStringandthat. If thisNumericStringis shorter thanthat,thisElemvalues are used to pad the result. Ifthatis shorter than thisNumericString,thatElemvalues are used to pad the result.
- def zipWithIndex: Iterable[(Char, Int)]
Zips this
NumericStringwith its indices.Zips this
NumericStringwith its indices.- returns
A new
Iterablecontaining pairs consisting of all characters of thisNumericStringpaired with their index. Indices start at0.
scala> NumericString("123").zipWithIndex res41: scala.collection.immutable.IndexedSeq[(Char, Int)] = Vector((1,0), (2,1), (3,2))
Example: