package conversions
- Alphabetic
- Public
- Protected
Type Members
- abstract class SeqUtilCompanion extends AnyRef
Value Members
- object DurationOps
Implicits for writing readable com.twitter.util.Durations.
Implicits for writing readable com.twitter.util.Durations.
import com.twitter.conversions.DurationOps._ 2000.nanoseconds 50.milliseconds 1.second 24.hours 40.days
Example: - object MapOps
Implicits for converting Maps.
Implicits for converting Maps.
import com.twitter.conversions.MapOps._ Map(1 -> "a").mapKeys { _.toString } Map(1 -> "a").invert Map(1 -> "a", 2 -> "b").filterValues { _ == "b" } Map(2 -> "b", 1 -> "a").toSortedMap
Example: - object PercentOps
Implicits for turning
x.percent
(wherex
is anInt
orDouble
) into aDouble
scaled to where 1.0 is 100 percent.Implicits for turning
x.percent
(wherex
is anInt
orDouble
) into aDouble
scaled to where 1.0 is 100 percent.import com.twitter.conversions.PercentOps._ 1.percent == 0.01 100.percent == 1.0 99.9.percent == 0.999 500.percent == 5.0 -10.percent == -0.1
- Note
Negative values, fractional values, and values greater than 100 are permitted.
Example: - object SeqOps
Implicits for converting Seqs.
Implicits for converting Seqs.
import com.twitter.conversions.SeqOps._ Seq("a", "and").createMap(_.size, _) Seq("a", "and").groupBySingleValue(_.size) Seq("a", "and").findItemAfter("a") var numStrings = 0 Seq(1, 2) foreachPartial { case e: Int => numStrings += 1 }
Example: - object SeqUtil
- object StorageUnitOps
Implicits for writing readable com.twitter.util.StorageUnits.
Implicits for writing readable com.twitter.util.StorageUnits.
import com.twitter.conversions.StorageUnitOps._ 5.bytes 1.kilobyte 256.gigabytes
Example: - object StringOps
- object ThreadOps
Implicits for turning a block of code into a Runnable or Callable.
- object TupleOps
Implicits for converting tuples.
Implicits for converting tuples.
import com.twitter.conversions.TupleOps._ Seq(1 -> "tada", 2 -> "lala").toKeys Seq(1 -> "tada", 2 -> "lala").mapValues(_.size) Seq(1 -> "tada", 2 -> "lala").groupByKeyAndReduce(_ + "," + _) Seq(1 -> "tada", 2 -> "lala").sortByKey
Example: - object U64Ops