<commit_before>package huhong.scala.navigator

import java.io.Serializable
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._


class Navigator[T <: Serializable](val datas: java.util.List[T], val count: Long, val page: Int, val pagesize: Int) extends Serializable {

  def this(datas: List[T], count: Long, page: Int, pagesize: Int) = this(datas.asJava, count, page, pagesize)

  val totalPage = ((count + pagesize - 1) / pagesize).toInt

  def isNext = (pagesize + 1) * page >= count

  def isPrev = page != 0
}

object Navigator {
  def getPageRange(count: Long, page: Int, pagesize: Int) = {
    count match {
      case 0L => PageRange(0, pagesize)
      case _ => {
        val begin = page * pagesize
        if (begin > count) {
          PageRange(0, pagesize)
        } else {
          PageRange(begin, begin + pagesize)
        }
      }
    }
  }

  def apply[T <: Serializable](datas: java.util.List[T], count: Long, page: Int, pagesize: Int) = new Navigator[T](datas, count, page, pagesize)
  def apply[T <: Serializable](datas: List[T], count: Long, page: Int, pagesize: Int) = new Navigator[T](datas, count, page, pagesize)
}

case class PageRange(val begin: Int, val end: Int)<commit_msg>navi bug fixed<commit_after>package huhong.scala.navigator

import java.io.Serializable
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._


class Navigator[T <: Serializable](val datas: java.util.List[T], val count: Long, val page: Int, val pagesize: Int) extends Serializable {

  def this(datas: List[T], count: Long, page: Int, pagesize: Int) = this(datas.asJava, count, page, pagesize)

  lazy val totalPages = (count - 1) / pagesize + 1

  def hasNext = (pagesize * page < count)

  def hasPrev = page > 0
}

object Navigator {
  def getPageRange(count: Long, page: Int, pagesize: Int) = {
    count match {
      case 0L => PageRange(0, pagesize)
      case _ => {
        val begin = page * pagesize
        if (begin > count) {
          PageRange(0, pagesize)
        } else {
          PageRange(begin, begin + pagesize)
        }
      }
    }
  }

  def apply[T <: Serializable](datas: java.util.List[T], count: Long, page: Int, pagesize: Int) = new Navigator[T](datas, count, page, pagesize)

  def apply[T <: Serializable](datas: List[T], count: Long, page: Int, pagesize: Int) = new Navigator[T](datas, count, page, pagesize)
}

case class PageRange(val begin: Int, val end: Int)
{'fraction_non_alphanumeric': 0.1281947261663286, 'fraction_numerical': 0.00486815415821501, 'mean_word_length': 3.4035714285714285, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '136209', 'n_tokens_mistral': 842, 'n_tokens_neox': 802, 'n_words': 241}