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
/** | |
* A Set is a data structure that contains multiple (zero or more) elements. | |
* - The elements in the Set are unique. (no duplication) | |
* - The elements in the Set are not kept in given order. (unordered) | |
*/ | |
class MySet { | |
/** | |
* This property shows the number of elements that are currently available in the Set. | |
*/ | |
var size: Int = 0 |
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 io.dahgan | |
/** | |
* Queue is a data structure that stores some elements and these elements can be received in FIFO order. | |
* That means the first element that is inserted to queue would be the first one that can be removed. | |
* | |
* Our queue has a limited capacity and can NOT store element more than its capacity. | |
* | |
* Note to developer: | |
* - define an array of integers to keep the queue elements. |
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 io.dahgan | |
/** | |
* Stack is a data structure that stores some elements and these elements can be received in LIFO order. | |
* That means the last element that is pushed to stack would be the first one that can be poped. | |
* | |
* Our stack has a limited capacity and can not store element more than its capacity. | |
* | |
* Note to developer: | |
* - define an array of integers to keep the stack elements. |
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
/** | |
* A function that takes TWO arrays of Integer, compares them and then returns: | |
* - 1, if the first array is greater than second one | |
* - -1, if the second array is greater tan first one | |
* - 0, if both arrays are the same. | |
* | |
* How to Compare? | |
* Starting from index 0, compare the elements of both array in the same positions until you find one is bigger than the other. | |
* | |
* Examples: |
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
/** | |
* ** Spec productions | |
* | |
* These are copied directly from the YAML specification, with some changes to adapt to Kotlin language syntax and | |
* also ease some of the decisions. | |
* | |
* See: http://www.yaml.org/spec/1.2/spec.html | |
*/ | |
/** |
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
fun main(args: Array<String>) { | |
val vertx = Vertx.vertx() | |
vertx.createHttpServer().requestHandler { request -> | |
request.response().end("Hello World!") | |
}.listen(8080) { result -> | |
if (result.succeeded()) { | |
vertx.createHttpClient().getNow(8080, "localhost", "/") { response -> | |
response.bodyHandler { body -> println("Server Response: ${body.toString()}") } |
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
class MySpeck extends Specification { | |
def "check sum of two integer"() { | |
given: "we have two integers, 10 and 20" | |
def a = 10 | |
def b = 20 | |
when: "we add these two numbers" | |
def c = 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
test fun `testing a simple add operation`() { | |
assertEquals(4, 2 + 2, "2 + 2 = 4") | |
} |
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
/opt/jdk1.8.0/bin/java -Didea.launcher.port=7533 -Didea.launcher.bin.path=/opt/idea-IU-129.161/bin -Dfile.encoding=UTF-8 -classpath /opt/jdk1.8.0/jre/lib/rt.jar:/opt/jdk1.8.0/jre/lib/javaws.jar:/opt/jdk1.8.0/jre/lib/charsets.jar:/opt/jdk1.8.0/jre/lib/jfr.jar:/opt/jdk1.8.0/jre/lib/jsse.jar:/opt/jdk1.8.0/jre/lib/jce.jar:/opt/jdk1.8.0/jre/lib/resources.jar:/opt/jdk1.8.0/jre/lib/management-agent.jar:/opt/jdk1.8.0/jre/lib/plugin.jar:/opt/jdk1.8.0/jre/lib/deploy.jar:/opt/jdk1.8.0/jre/lib/ext/sunec.jar:/opt/jdk1.8.0/jre/lib/ext/sunpkcs11.jar:/opt/jdk1.8.0/jre/lib/ext/dnsns.jar:/opt/jdk1.8.0/jre/lib/ext/cldrdata.jar:/opt/jdk1.8.0/jre/lib/ext/sunjce_provider.jar:/opt/jdk1.8.0/jre/lib/ext/zipfs.jar:/opt/jdk1.8.0/jre/lib/ext/localedata.jar:/home/me/code/string-intern/out/production/string-intern:/opt/idea-IU-129.161/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain StringKeyTest | |
With Warm up String: 82373148 | |
With Warm up Object: 30957921 | |
With Warm up Builder: 72123213 | |
With Warm up String: 61386367 | |
With W |
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
import java.math.BigInteger; | |
import java.security.SecureRandom; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
/** | |
* @author me | |
*/ |
NewerOlder