-1 ^ (-1<<n) = 2^n-1
原理:将最右n位变成1
- -1 表示 1111 1111 1111 1111
- 移4位后 1111 1111 1111 1111 0000
- 高位舍去,异或
1111 1111 1111 0000
^ 1111 1111 1111 1111
import bisect | |
import heapq | |
import time | |
from collections import namedtuple | |
timeouts = namedtuple('Timeouts', ['deadline', 'task']) | |
class Task(object): | |
def __init__(self, schedule, name): |
import selectors | |
import errno | |
import sys | |
class IOLoop(object): | |
@classmethod |
import socket | |
import time | |
tic = lambda x: '\nat %1.1f second' % (time.time() - x) | |
def get_request(path): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect(('127.0.0.1', 8088)) | |
sock.setblocking(0) |
import selectors | |
import errno | |
import sys | |
class IOLoop(object): | |
@classmethod |
def future_add_done_callback(future, callback): | |
if future.done(): | |
callback(future) | |
else: | |
future.add_done_callback(callback) |
package main | |
import ( | |
"fmt" | |
"time" | |
"math/rand" | |
) | |
func main() { | |
c := fanIn(boring("joe"),boring("Ann")) |
CREATE TABLE public.friend (
uid1 INTEGER,
uid2 INTEGER
);
CREATE INDEX index_uid1 ON friend USING BTREE (uid1);
REATE INDEX index_uid2 ON friend USING BTREE (uid2);
表friend
记录user1和user2是朋友关系,而且只会记录单方,(1,2)和(2,1)是一样的。