Compare commits
2 Commits
98a3cf9ebe
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d77d00cb37 | |||
| 9845c00a9f |
@@ -1,2 +0,0 @@
|
||||
REVIEWBOARD_URL = 'http:///'
|
||||
REPOSITORY = 'PrimitiveCollections'
|
||||
@@ -106,6 +106,12 @@ class MultiwayLongMerger {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next power of two that is equal or larger than i.
|
||||
* or more formally: x where x = 2^n and x >= i for n ∈ ℕ and n minimal
|
||||
* @param i some positive integer
|
||||
* @return smallest integer that is a power of two and equal or larger than i
|
||||
*/
|
||||
private static int nextPowOfTwo(int i) {
|
||||
return Integer.highestOneBit(i - 1) << 1;
|
||||
}
|
||||
@@ -164,22 +170,32 @@ class MultiwayLongMerger {
|
||||
}
|
||||
|
||||
/**
|
||||
* A heap is a tree where the value of the parent is smaller than the value of its children.
|
||||
* <pre>
|
||||
* 7
|
||||
* 3
|
||||
* 8
|
||||
* 1
|
||||
* 9
|
||||
* 4
|
||||
* 10
|
||||
* 0
|
||||
* 11
|
||||
* 5
|
||||
* 12
|
||||
* 2
|
||||
* 13
|
||||
* 6
|
||||
* 23
|
||||
* 13
|
||||
* 14
|
||||
* 9
|
||||
* 37
|
||||
* 24
|
||||
* 77
|
||||
* 5
|
||||
* 44
|
||||
* 35
|
||||
* 93
|
||||
* 7
|
||||
* 29
|
||||
* 27
|
||||
* 31 ┌────────────────────────┬────┐
|
||||
* ┌────┼──────────────┬────┐ │ │
|
||||
* ┌────┬────┐ │ │ │ │ │ │
|
||||
* ┏━━┷━┳━━━━┳━━━━┳━━┷━┳━━┷━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓
|
||||
* ┃ 5 ┃ 9 ┃ 7 ┃ 13 ┃ 24 ┃ 35 ┃ 27 ┃ 23 ┃ 14 ┃ 37 ┃ 77 ┃ 93 ┃ 29 ┃ 31 ┃
|
||||
* ┗━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┛
|
||||
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 (array indices)
|
||||
* │ │ │ │ │ │
|
||||
* └────┼────┴────┘ │ │
|
||||
* └──────────────┴────┘
|
||||
* </pre>
|
||||
*/
|
||||
private void init() {
|
||||
|
||||
Reference in New Issue
Block a user