- Don't use PC while benchmarikng!
- Laptop power should be pluged-in
- Maven: 3.3.9
- Java: 1.8.0_111
- SBT: 0.13.13
- Systems under test:
[4278U]
MacOS Sierra, mbp mid 2014 (MGX72RU/A), core i5-4278U, 8 Gb, 128 Gb SSD[3570K]
Ubuntu 16.10, core i5-3570K OC @ 4.3 Ghz, 8 Gb, 240 Gb SSD Kingston SKC300S
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
private val openingBrackets = "([{<" | |
private val closingBrackets = ")]}>" | |
fun String.isBalancedComplex(): Boolean = | |
fold(Stack<Char>()) { acc, c -> | |
when (c) { | |
// For kotlin beginners: `apply(..)` == `{acc.push(c); acc}`: just a shorthand to eliminate 1 line of code, nothing fancy here | |
in openingBrackets -> acc.apply { push(c) } | |
in closingBrackets -> { | |
if (acc.isEmpty()) return false // leading closing braket like ')))' |