This file contains hidden or 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 static java.lang.Math.max; | |
| import static java.lang.Math.min; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.Random; | |
| public class AVLTree<T extends Comparable<? super T>> { | |
| private Node root; |
This file contains hidden or 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.io.BufferedReader; | |
| import java.io.FileReader; | |
| import java.io.IOException; | |
| import java.io.Reader; | |
| import java.util.regex.Matcher; | |
| import java.util.regex.Pattern; | |
| public enum StepCounter { | |
| INSTANCE; |
This file contains hidden or 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 com.example; | |
| public class Control { | |
| public static void main(String[] args) { | |
| Model.Rectangle r1 = new Model.Rectangle(1, 2, 3, 4); | |
| Model.Rectangle r2 = new Model.Rectangle(2, 3, 5, 5); | |
| new Control().execute(r1, r2); | |
| } |
This file contains hidden or 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
| interface Debugprintable { | |
| enum ErrStatus { | |
| NO_ERROR(0), FILE_ERROR(1), MEMORY_ERROR(2); | |
| private final int statusCode; | |
| private ErrStatus(int statusCode) { | |
| this.statusCode = statusCode; | |
| } | |
| @Override | |
| public String toString() { | |
| return Integer.toString(statusCode); |
This file contains hidden or 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.lang.reflect.Field; | |
| import java.util.Date; | |
| public final class Tuples { | |
| public static void main(String[] args) { | |
| Tuple3<Integer, String, Date> tpl = Tuples.get(1, "a", new Date()); | |
| System.out.println(tpl._1); | |
| System.out.println(tpl); | |
| } |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>homebrew.mxcl.jenkins</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/usr/bin/java</string> | |
| <string>-jar</string> |
This file contains hidden or 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
| trait ExSeq[+A] { | |
| self: Seq[A] => | |
| def mapBetween[B](f:(A,A)=>B): Iterator[B] = { | |
| sliding(2).map(s=>f(s(0),s(1))) | |
| } | |
| } | |
| object ExSeq { |
This file contains hidden or 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 mapBetween { | |
| def main(args:Array[String]) = { | |
| val range = new Range(1, 10, 1) with ExtSeq[Int] | |
| println(range.mapBetween(_+_) mkString ",") | |
| println(range.mapBetween(_*_) mkString ",") | |
| println(range.mapBetween(_-_) mkString ",") | |
| val range2 = 1 to 10 | |
| println(range2.mapBetween(_+_) mkString ",") | |
| println(range2.mapBetween(_*_) mkString ",") |
This file contains hidden or 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 mapBetween2 { | |
| def main(args:Array[String]) = { | |
| val range = 1 to 10 | |
| println(mapBetween(range)(_+_) mkString ",") | |
| println(mapBetween(range)(_*_) mkString ",") | |
| println(mapBetween(range)(_-_) mkString ",") | |
| } | |
| def mapBetween[A,B,T>:A](seq:Seq[A])(f:(T,T)=>B): Iterator[B] = { | |
| seq.sliding(2).map(s=>f(s(0),s(1))) |
This file contains hidden or 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 MapBetween { | |
| def main(args:Array[String]) = { | |
| val range = 1 to 10 | |
| println(mapBetween(range, (a1:Int,a2:Int)=>a1+a2)) | |
| println(mapBetween(range, (a1:Int,a2:Int)=>a1*a2)) | |
| println(mapBetween(range, (a1:Int,a2:Int)=>a1-a2)) | |
| } | |
| def mapBetween[A,B,T>:A](seq:Seq[A], f:(T,T)=>B): Seq[B] = { | |
| ((Seq[B](), seq.head) /: seq.tail) {(tup:(Seq[B], A), a:A) => (tup._1 :+ f(tup._2, a), a)}._1 |
NewerOlder