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
public class Main { | |
public static void main(String[] args) { | |
Timeline timeline = new TimelineImpl(); | |
//チェーンメソッドで色々できます。 | |
timeline.postList(777).limit(15).offset(100).get(); | |
timeline.postList(55).get(); | |
} | |
} |
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
trait Queue[T]{ | |
def head:T | |
def tail:Queue[T] | |
def append(x:T):Queue[T] | |
} | |
// クラス実装自体を格納するオブジェクト | |
object Queue{ | |
// 待ち行列クラスの実装を行う非公開クラス | |
// 実装内容はこれまでのQueueと同じ |
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 Queue { | |
// 初期要素xsを利用して待ち行列を構築しますね | |
def apply[T](xs:T*) = new Queue[T](xs.toList, Nil) | |
} | |
class Queue[T] private ( | |
// 待ち行列の正順リスト | |
private val leading:List[T], | |
// 待ち行列の逆順リスト | |
private val trailing:List[T] |
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 Queue[T] private ( | |
// 待ち行列の正順リスト | |
private val leading:List[T], | |
// 待ち行列の逆順リスト | |
private val trailing:List[T] | |
){ | |
// 連続パラメータを初期要素とする補助コンストラクタ | |
def this(elems:T*) = this(elems.toList, Nil) |
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 Queue[T]( | |
// 待ち行列の正順リスト | |
private val leading:List[T], | |
// 待ち行列の逆順リスト | |
private val trailing:List[T] | |
){ | |
// 2つのリストの同期 | |
private def mirror = { | |
if(leading.isEmpty) new Queue(trailing.reverse, Nil) | |
else this |
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 SlowHeadQueue[T](elems:List[T]){ | |
// 末尾を取ってくれば先頭要素 | |
def head = smele.last | |
// 末尾以外を取ればtailの動作になる | |
def tail = new SlowHeadQueue(smele.init) | |
// 連結処理をつかって高速にできる | |
def append(x:T) = new SlowHeadQueue( x :: smele ) | |
} |
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 SlowAppendQueue[T](elems:List[T]){ | |
// headはList.headを利用 | |
def head = elem.head | |
// tailもList.tailから生成 | |
def tail = new SlowAppendQueue(elems.tail) | |
// ::: メソッドで結合 | |
def append(x:T) = new SlowAppendQueue(elems ::: List(x)) |
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
public class ThriftClient { | |
public static void main(String[] args) { | |
new com.twitter.finagle.thrift.thrift.ClientId(); | |
//Thrift プロトコルベースのリクエストを送信するクライアントを生成 | |
Service<ThriftClientRequest, byte[]> service = ClientBuilder | |
.safeBuild(ClientBuilder.get() | |
.hosts(new InetSocketAddress(8080)) | |
.codec(ThriftClientFramedCodec.get()) | |
.hostConnectionLimit(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
require 'formula' | |
# Documentation: https://github.com/mxcl/homebrew/wiki/Formula-Cookbook | |
class Thriftfinagle < Formula | |
homepage 'https://github.com/benjyw/thrift-0.8.0-finagle' | |
version '0.8.0' | |
url 'https://github.com/benjyw/thrift-0.8.0-finagle/tarball/master' | |
sha1 'd5d87bc8b658c81b5095b701512085017f58564e' |
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
USE last_insert_test; | |
CREATE TABLE table1 ( | |
id1 int | |
) ENGINE=InnoDB; | |
CREATE TABLE table2 ( | |
id2 int | |
) ENGINE=InnoDB; |