package util
Additional utilities that need a home
- Alphabetic
- By Inheritance
- util
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class DoubleMap extends AnyRef
- trait DoubleTotalOrderTrait extends Order[Double] with Hash[Double]
An Order[Double] instance which produces a total order by ordering NaNs above all other Doubles
An Order[Double] instance which produces a total order by ordering NaNs above all other Doubles
Contrary to the specification of cats, the DoubleOrdering in cats.kernel is not total because NaN is not ordered (all comparisons return false). This behaviour is consistent with IEEE-754, but not very practical.
java.lang.Double.compare orders NaN to be largest of all Doubles.
See https://github.com/scala/scala/pull/8721 See https://github.com/scala/scala/blob/39e82c3f904380f0b40d106723747faf881640d4/src/library/scala/math/Ordering.scala#L465
- trait FloatTotalOrderTrait extends Order[Float] with Hash[Float]
See DoubleTotalOrder
- class IntMap extends AnyRef
- final class LongMap extends AnyRef
This class implements mutable maps with Long keys based on a hash table with open addressing.
This class implements mutable maps with Long keys based on a hash table with open addressing.
Basic map operations on single entries, including
contains
andget
, are typically substantially faster withLongMap
than HashMap. Methods that act on the whole map, includingforeach
andmap
are not in general expected to be faster than with a generic map, save for those that take particular advantage of the internal structure of the map:foreachKey
,foreachValue
,mapValuesNow
, andtransformValues
.Maps with open addressing may become less efficient at lookup after repeated addition/removal of elements. Although
LongMap
makes a decent attempt to remain efficient regardless, callingrepack
on a map that will no longer have elements removed but will be used heavily may save both time and storage space.This map is not intended to contain more than 229 entries (approximately 500 million). The maximum capacity is 230, but performance will degrade rapidly as 2^30 is approached.
- trait OrderInstances extends AnyRef
Value Members
- def buildStr(count: Int, total: Int, callback: (Int) => String, break: => String = " ... "): String
Creates a string out of count number of elements extracted from total elements between offsets [0 ...
Creates a string out of count number of elements extracted from total elements between offsets [0 ... count / 2) and (total - count / 2 ... total), using a callback that generates a string at each offset, and inserting a break string if count > total.
- count
Number of elements to print
- total
Total number of elements in sequence
- callback
Generates a string at each offset
- break
Produces a string to insert as a break
- final def dividePositiveRoundUp(a: Long, b: Long): Long
- Annotations
- @inline()
- final def dividePositiveRoundUp(a: Int, b: Int): Int
- Annotations
- @inline()
- def grab[T](arr: Array[T], n: Int): Seq[T]
Takes n elements from the front and from the back of array
Takes n elements from the front and from the back of array
- arr
Array
- n
Number of elements to take
- object Concat
Provides a way to append two arrays of possibly different types together by intelligently promoting primitive types where possible.
Provides a way to append two arrays of possibly different types together by intelligently promoting primitive types where possible.
Key method is Concat.append(array1, array2)
- object DoubleTotalOrder extends DoubleTotalOrderTrait
- object FloatTotalOrder extends FloatTotalOrderTrait
- object LongMap