剪贴板:
:reg 查看寄存器
"+y 复制到系统剪贴板,然后ctr-v粘帖到其他地方
""为临时剪贴板
格式化**************:
gg=G
dG全部剪切
gg v G全选
| object Ternary { | |
| implicit def coalescingOperator[T](pred: T) = new { | |
| def ??[A >: T](alt: =>A) = if (pred == null) alt else pred | |
| } | |
| implicit def elvisOperator[T](alt: =>T) = new { | |
| def ?:[A >: T](pred: A) = if (pred == null) alt else pred | |
| } | |
| } |
剪贴板:
:reg 查看寄存器
"+y 复制到系统剪贴板,然后ctr-v粘帖到其他地方
""为临时剪贴板
格式化**************:
gg=G
dG全部剪切
gg v G全选
| import java.util.Collection; | |
| import java.util.SortedMap; | |
| import java.util.TreeMap; | |
| public class ConsistentHash<T> { | |
| private final HashFunction hashFunction; | |
| private final int numberOfReplicas; | |
| private final SortedMap<Integer, T> circle = new TreeMap<Integer, T>(); | |
| '''hashCode | |
| // equals 为true的时候 ,hashCode 函数为true | |
| // object 的hashCode是32为内存地址 | |
| // 作用是放容器的时候,避免重复,hash存储。 | |
| '''快速排序 | |
| http://literateprograms.org/Special:Downloadcode/Quicksort_%28Java%29 |
| '''print 格式化 => String 格式化,适用于python 的print语法 | |
| println("welcome %s ." format("jack")) | |
| '''Java 版 | |
| String s = String.format("%d", factor); | |
| System.out.println(s); | |
| '''1.格式 | |
| %s 为字符串 |
| case class Address(no: Int, street: String, city: String, state: String, zip: String) | |
| trait LabelMaker[T] { | |
| def toLabel(value: T): String | |
| } | |
| trait te{ | |
| implicit object StringLabelMaker extends LabelMaker[String] { | |
| def toLabel(s: String) = s | |
| } |
| trait Clickable{def click} | |
| abstract class Widge | |
| class Button(val lable:String) extends Widge{ def click {}} | |
| trait Subject { | |
| type Obser = {def receive(who:Any,ms:String)} | |
| private var subs = List[Obser]() | |
| def addObser(obs:Obser) = subs::=obs | |
| def notifyObser(ms:String) = subs foreach { _ receive (this, ms)} |
| //分代,计数,标记,复制 | |
| 一)GC类型 | |
| GC有两种类型:Scavenge GC和Full GC。 | |
| 1)Scavenge GC | |
| 一般情况下,当新对象生成,并且在Eden申请空间失败时,就好触发Scavenge GC,堆Eden区域进行GC,清除非存活对象,并且把尚且存活的对象移动到Survivor区。然后整理Survivor的两个区。 | |
| 2)Full GC | |
| 对整个堆进行整理,包括Young、Tenured和Perm。Full GC比Scavenge GC要慢,因此应该尽可能减少Full GC。有如下原因可能导致Full GC: | |
| a)Tenured被写满 |