Lines Matching +full:alloc +full:- +full:ranges
11 available after provided value". Note that next-after will
14 The free lists are thread-locked so that this code can be used
22 >>> a.alloc()
26 >>> a.alloc(8)
74 >>> r = NumAlloc(0, -1)
76 NumAlloc(0, -1)
77 >>> r.alloc() is None
83 Note that r.alloc() starts from where you last left off, even if
86 >>> r.alloc()
89 >>> r.alloc()
96 argument to r.alloc():
98 >>> r.alloc()
100 >>> r.alloc(r.min_val)
103 Providing a number to alloc() tries to allocate that number,
106 >>> r.alloc(49)
108 >>> r.alloc(49)
110 >>> r.alloc(99999)
117 would not be thread-safe.
148 Remember that self.avail is a list of avaliable ranges of
173 high = len(self.avail) - 1
175 mid = low + ((high - low) // 2)
179 high = mid - 1
191 def alloc(self, val=None): member in NumAlloc
226 # Value val is available - take it.
244 pair[1] = val - 1
247 pair[1] = val - 1
272 # since coalesced ranges make for shorter copies.
275 while len(values) and values[-1] == val - 1:
281 If needed, widen our range to include new high val -- i.e.,
294 If needed, widen our range to include new low val -- i.e.,
308 a one-element range.
329 abuts_below = self.avail[i - 1][1] + 1 == val
333 abuts_above = self.avail[i][0] - 1 == highval
338 # 2. abuts below only: adjust previous (i-1'th) block
344 self.avail[i - 1][1] = self.avail[i][1]
349 self.avail[i - 1][1] = highval
371 r = NumAlloc(0, 2**16 - 1)
373 r.alloc(i)
374 print('worst case alloc: len(r.avail) = {0}'.format(len(r.avail)))
375 for i in xrange(r.max_val - 1, r.min_val, -2):