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 datastructure.stackqueue; | |
interface Stack { | |
void push(Object obj); | |
Object pop(); | |
boolean isEmpty(); | |
} | |
class ArrayStack implements Stack { | |
private Object[] theArray; |
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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
/** | |
* change the value of a specified query string in a url. | |
*/ | |
def updateUrlParameterValWithRegex(url, paraName, paraVal) { | |
assert url | |
def (path, paras) = url.tokenize('?') | |
println "the original url parameters:\n ${paras}" | |
def updatedUrl = paras.replaceFirst(/${paraName}=\w*/, "${paraName}=${paraVal}") | |
println "the updated url parameters:\n ${updatedUrl}" | |
"${path}${updatedUrl}" |
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 com.thomson.jcip.ch5.building; | |
import java.util.Vector; | |
/** | |
* 验证同步集合类存在的问题:在同步集合类上执行复合操作有可能出现问题 | |
* | |
* comes from the chapter5 of JCIP | |
* | |
* 同步集合类本身是线程安全的,所以将对象的状态委托给这些同步集合类来管理,就能保证线程安全性。但是还存在一种例外,如果在同一个集合类上执行复合操作,那么就会产生一些不符合预期的问题。 |