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 HeapSort { | |
def sort(source: Array[Int]): Unit = { | |
buildHeap(source) | |
lineUp(source) | |
} | |
private def buildHeap(source: Array[Int]): Unit = { | |
def moveUp(source: Array[Int], idx: Int): Unit = { | |
if (idx > 0) { | |
val pIdx = Math.round(idx * 0.5f) - 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
object MergeSort { | |
def sort(source: Array[Int]): Unit = { | |
branch(source, 0, source.length) | |
} | |
private def sortAndMerge(source: Array[Int], | |
offset0: Int, len0: Int, | |
offset1: Int, len1: Int): Unit = { | |
val buffer = new Array[Int](len0 + len1) |
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
intToBase64 = [ | |
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', | |
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', | |
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', | |
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', | |
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' | |
] | |
def encode(InputStream is) { | |
int countByte = 2 |
NewerOlder