This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Pagination { | |
def apply[T](page: ListPage[T], pageSize: Int)(navi: Int => Call) = | |
new Pagination(page.totalCount, page.firstIndex, page.runover, pageSize)(navi) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
import play.api.mvc.Call | |
class Pagination(cnt: Int, pos: Int, val runover: Boolean, val pageSize: Int = 20, | |
val forwardCnt: Int = 4, val backwardCnt: Int = 4, val headCnt: Int = 3, val tailCnt: Int = 4, | |
val indexByPage: Boolean = false, val indexByPageIndex: Boolean = false, val independentVicinity: Boolean = false, | |
val consoleEnds: Boolean = false, val duplicateEnds: Boolean = false)(navi: Int => Call) { | |
outer => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
public class PaginationData { | |
public static final String SPECIAL_RUNOVER = "runover"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Pagination { | |
def apply[T](page: ListPage[T], pageSize: Int)(navi: Int => Call): PaginationData = { | |
val pd = new PaginationData | |
pd.setPageSize(pageSize) | |
pd.setRunover(page.runover) | |
pd.configure(page.totalCount, page.firstIndex) | |
pd.setAddressAdapter(new PageAddressAdapter { | |
override def makePageAddress(offset: Int): Call = navi(offset) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tailrec | |
def accumBits(remainingText: List[Char], accum: List[Int]): List[Int] = | |
if (remainingText.isEmpty) accum | |
else accumBits(remainingText.tail, accum ++ encodeChar(remainingText.head)) | |
accumBits(text, List()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(n: Int): Int = { | |
@tailrec | |
def accumFactors(accumulator: Int, n: Int): Int = | |
if (n == 0) accumulator | |
else accumFactors(accumulator * n, n - 1) | |
accumFactors(1, n) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tailrec | |
def gcd(a: Int, b: Int): Int = | |
if (b == 0) a else gcd(b, a % b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(n: Int): Int = | |
if (n == 0) 1 else n * factorial(n - 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cz.vmencik.sandbox.nullcheck; | |
interface AuthorizedUser { | |
User getUser(); | |
} | |
interface User { | |
Group getGroup(); | |
} |