Skip to content

Instantly share code, notes, and snippets.

Avatar

象道 Kejia

  • OTTAWA, ONTARIO, CANADA
View GitHub Profile
@Kejia
Kejia / linear_probing.java
Last active Sep 18, 2017
java: linear probing.
View linear_probing.java
// linear probing a null slot in an M-length array (M >= N)
for (i = start; myarray[i] != null && myarray[i] != target; i = (i+1) % M)
...
@Kejia
Kejia / sleep_with_promise.es
Created Jul 26, 2017
使用promise定义的sleep函
View sleep_with_promise.es
const sleep = second => {
const millisecond = second * 1000;
const r = new Promise((resolve, reject) => setTimeout(() => resolve(`this slept ${second} seconds`),
millisecond));
return r.then(alert);
};
You can’t perform that action at this time.