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
/// <summary> | |
/// The removing buffer. | |
/// </summary> | |
private readonly LinkedList<T> _itemsToAdd = new LinkedList<T>(); | |
private readonly Dictionary<T, LinkedListNode<T>> _itemNodesToAdd = new Dictionary<T, LinkedListNode<T>>(); | |
/// <summary> | |
/// The adding buffer. | |
/// </summary> | |
private readonly HashSet<T> _itemToRemove = new HashSet<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
// The code below would print overlapped A and B sequences like: | |
// ... | |
// A | |
// A | |
// B | |
// B | |
// ... | |
// | |
// Please add multi-threading protection code to make sure that | |
// As and Bs are printed in the order of: |
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
// Usage: | |
// You cannot directly access Resource.state but only in | |
// the callback provided by Resource.register method. | |
// The callback would be invoked with a complete function | |
// when the resource is free to access. Call the function | |
// when you finish to use the resource to release it. | |
var Resource = (function () { | |
var waitingCallbacks = []; |
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
var supportDefineProperty = (function () { | |
var i = 0; | |
var getter = function () { | |
if (i === 0) { | |
throw new Error("Execute too soon."); | |
} | |
return i; | |
}; |
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
var bubbleSort = function (array, _) { | |
for (var i = 0; i < array.length; i++) { | |
for (var j = 0; j < array.length - i - 1; j++) { | |
var r = compareAsync(array[j], array[j + 1], _); | |
if (r > 0) swapAsync(array, j, j + 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
server.getAsync = function (pattern, task) { | |
server.get(pattern, function (req, res, next) { | |
task(req, res).addEventListener("complete", function () { | |
// error would be undefined if everything's fine. | |
next(this.error); | |
}).start(); | |
}); | |
} | |
server.getAsync(":name", eval(Wind.compile("async", function (req, res) { |
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
var nativeRandomLCG = function (seed) { | |
return function () { | |
seed = (214013 * seed + 2531011) % 0x100000000; | |
return seed * (1.0 / 4294967296.0); | |
}; | |
}; | |
var evalRandomLCG = function (seed) { | |
var randomLCG = eval("(" + nativeRandomLCG.toString() + ")"); | |
return randomLCG(seed); |
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 Order { | |
void resubmit( IBookStoreDao dao ) { | |
//逻辑判断; | |
//设置订单状态; | |
//设置购买项状态; | |
dao.update(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
public class Order | |
{ | |
public int OrderID { get; set; } | |
public string Name { get; set; } | |
public DateTime CreateAt { get; set; } | |
} | |
public interface IOrderDao |
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
/dev/disk0 | |
#: TYPE NAME SIZE IDENTIFIER | |
0: GUID_partition_scheme *320.1 GB disk0 | |
1: EFI 209.7 MB disk0s1 | |
2: Apple_HFS Lion 319.2 GB disk0s2 | |
3: Apple_Boot 650.0 MB disk0s5 |