All Downloads are FREE. Search and download functionalities are using the official Maven repository.

overflowdb.traversal.NumericTraversal.scala Maven / Gradle / Ivy

There is a newer version: 1.193
Show newest version
package overflowdb.traversal

class NumericTraversal[N](val traversal: Iterator[N]) extends AnyVal {
  type Traversal[A] = Iterator[A]
  def greaterThan(n: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(numeric.gt(_, n))

  def greaterThanEqual(n: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(numeric.gteq(_, n))

  def lessThan(n: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(numeric.lt(_, n))

  def lessThanEqual(n: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(numeric.lteq(_, n))

  def equiv(n: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(numeric.equiv(_, n))

  def between(startInclusive: N, endExclusive: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(n => numeric.gteq(n, startInclusive) && numeric.lt(n, endExclusive))

  def inside(startExclusive: N, endExclusive: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(n => numeric.gt(n, startExclusive) && numeric.lt(n, endExclusive))

  def outside(startInclusive: N, endInclusive: N)(implicit numeric: Numeric[N]): Traversal[N] =
    traversal.filter(n => numeric.lt(n, startInclusive) || numeric.gt(n, endInclusive))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy