Skip to content

Instantly share code, notes, and snippets.

/// <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>();
// 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:
// 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 = [];
var supportDefineProperty = (function () {
var i = 0;
var getter = function () {
if (i === 0) {
throw new Error("Execute too soon.");
}
return i;
};
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, _);
}
}
}
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) {
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);
class Order {
void resubmit( IBookStoreDao dao ) {
//逻辑判断;
//设置订单状态;
//设置购买项状态;
dao.update(this);
}
}
public class Order
{
public int OrderID { get; set; }
public string Name { get; set; }
public DateTime CreateAt { get; set; }
}
public interface IOrderDao
/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