コード例 #1
0
 def _resize(self, cap):  #Resize the Array list
     b = new_array(cap)
     for i in range(self.size):
         b[i] = self.a[(self.front + i) % self.size]
     self.a = b
     self.cap = cap
     self.front = 0
コード例 #2
0
 def __init__(self):
     super(XFastTrie, self).__init__()
     self.nil = self._new_node()
     self.t = new_array(w + 1)
     for i in range(w + 1):
         self.t[i] = LinearHashTable()
     self.t[0].add(self.r)
コード例 #3
0
ファイル: algorithms.py プロジェクト: GaganJotSingh/ods
def dfs2(g, r):
    c = new_array(g.n)
    s = SLList()
    s.push(r)
    while s.size() > 0:
        i = s.pop()
        if c[i] == white:
            c[i] = grey
            for j in g.out_edges(i):
                s.push(j)
コード例 #4
0
def dfs2(g, r):
    c = new_array(g.n)
    s = SLList()
    s.push(r)
    while s.size() > 0:
        i = s.pop()
        if c[i] == white:
            c[i] = grey
            for j in g.out_edges(i):
                s.push(j)
コード例 #5
0
def counting_sort(a, k):
    c = new_zero_array(k)
    for i in range(len(a)):
        c[a[i]] += 1
    for i in range(1, k):
        c[i] += c[i - 1]
    b = new_array(len(a))
    for i in range(len(a) - 1, -1, -1):
        c[a[i]] -= 1
        b[c[a[i]]] = a[i]
    return b
コード例 #6
0
ファイル: algorithms.py プロジェクト: GaganJotSingh/ods
def counting_sort(a, k):
    c = new_zero_array(k)
    for i in range(len(a)):
        c[a[i]] += 1 
    for i in range(1, k):
        c[i] += c[i-1]  
    b = new_array(len(a))
    for i in range(len(a)-1, -1, -1):
        c[a[i]] -= 1        
        b[c[a[i]]] = a[i]   
    return b
コード例 #7
0
 def resize(self, capacity, k, value):
     b = new_array(capacity)  #New array created
     index = 0  #the index is tracked
     for i in range(self.n + 1):
         if i == k:  #k is is specified index, adds an element
             b[i] = value
         else:
             b[i] = self.a[index]
             index += 1
     self.a = b
     self.capacity = capacity
コード例 #8
0
ファイル: linearhashtable.py プロジェクト: rugbyprof/ods
 def _resize(self):
     self.d = 1
     while ((1<<self.d) < 3*self.n): self.d += 1
     told = self.t
     self.t = new_array((1<<self.d))
     self.q = self.n
     for x in told:
         if x is not None and x != self.dl:
             i = self._hash(x)
             while self.t[i] is not None: 
                 i = (i+1) % len(self.t)
             self.t[i] = x
コード例 #9
0
ファイル: linearhashtable.py プロジェクト: zehsilva/ods
 def _resize(self):
     self.d = 1
     while ((1 << self.d) < 3 * self.n):
         self.d += 1
     told = self.t
     self.t = new_array((1 << self.d))
     self.q = self.n
     for x in told:
         if x is not None and x != self.dl:
             i = self._hash(x)
             while self.t[i] is not None:
                 i = (i + 1) % len(self.t)
             self.t[i] = x
コード例 #10
0
 def rebuild(self, u):
     ns = self._size(u)
     p = u.parent
     a = new_array(ns)
     self.pack_into_array(u, a, 0)
     if p == self.nil:
         self.r = self.build_balanced(a, 0, ns)
         self.r.parent = nil
     elif p.right == u:
         p.right = self.build_balanced(a, 0, ns)
         p.right.parent = p
     else:
         p.left = self.build_balanced(a, 0, ns)
         p.left.parent = p
コード例 #11
0
ファイル: scapegoattree.py プロジェクト: GaganJotSingh/ods
 def rebuild(self, u):
     ns = self._size(u)
     p = u.parent
     a = new_array(ns)
     self.pack_into_array(u, a, 0)
     if p == self.nil:
         self.r = self.build_balanced(a, 0, ns)
         self.r.parent = nil
     elif p.right == u:
         p.right = self.build_balanced(a, 0, ns)
         p.right.parent = p
     else:
         p.left = self.build_balanced(a, 0, ns)
         p.left.parent = p
コード例 #12
0
ファイル: algorithms.py プロジェクト: GaganJotSingh/ods
def radix_sort(a):
    for p in range(w//d):
        c = new_zero_array(1<<d)
        b = new_array(len(a))
        for i in range(len(a)):
            bits = (a[i] >> d*p)&((1<<d)-1) 
            c[bits] += 1 
        for i in range(1, 1<<d):
            c[i] += c[i-1]
        for i in range(len(a)-1, -1, -1):
            bits = (a[i] >> d*p)&((1<<d)-1)
            c[bits] -=1
            b[c[bits]] = a[i] 
        a = b
    return b
コード例 #13
0
def radix_sort(a):
    for p in range(w // d):
        c = new_zero_array(1 << d)
        b = new_array(len(a))
        for i in range(len(a)):
            bits = (a[i] >> d * p) & ((1 << d) - 1)
            c[bits] += 1
        for i in range(1, 1 << d):
            c[i] += c[i - 1]
        for i in range(len(a) - 1, -1, -1):
            bits = (a[i] >> d * p) & ((1 << d) - 1)
            c[bits] -= 1
            b[c[bits]] = a[i]
        a = b
    return b
コード例 #14
0
ファイル: fastarraystack.py プロジェクト: GaganJotSingh/ods
 def _resize(self):
     b = new_array(max(1, 2*self.n))
     b[0:self.n] = self.a[0:self.n]
     self.a = b
コード例 #15
0
 def resize(self, capacity):
     b = new_array(capacity)
     for i in range(self.n):
         b[i] = self.a[i]
     self.a = b
     self.capacity = capacity
コード例 #16
0
 def __init__(self):
     self.a = new_array(1)
     self.size = 0
     self.cap = len(self.a)
     self.front = 0
     self.empty = 0
コード例 #17
0
 def resize(self):
     b = new_array(max(2*self.n, 1))
     for i in range(self.n):
         b[i] = self.a[i]
     self.a = b    
コード例 #18
0
ファイル: arrayqueue.py プロジェクト: patmorin/ods
 def _resize(self):
     b = new_array(max(1, 2*self.n))
     for k in range(self.n):
         b[k] = self.a[(self.j+k) % len(self.a)]
     self.a = b
     self.j = 0
コード例 #19
0
 def __init__(self, x, h):
     self.x = x
     self.next = new_array(h+1)
     self.length = numpy.ones(h+1, dtype=int)
コード例 #20
0
ファイル: btree.py プロジェクト: rugbyprof/ods
 def __init__(self, btree):
     self.btree = btree
     self.keys = new_array(self.btree.b)
     self.children = new_int_array(self.btree.b+1, -1)
     self.id = self.btree.bs.place_block(self)
コード例 #21
0
ファイル: adjacencylists.py プロジェクト: GaganJotSingh/ods
 def _initialize(self):
     self.adj = new_array(self.n)
     for i in range(self.n):
         self.adj[i] = ArrayStack()
コード例 #22
0
ファイル: linearhashtable.py プロジェクト: zehsilva/ods
 def initialize(self):
     self.d = 1
     self.t = new_array((1 << self.d))
     self.q = 0
     self.n = 0
コード例 #23
0
 def grow(self):
     self.blocks.append(new_array(self.blocks.size() + 1))
コード例 #24
0
 def __init__(self, btree):
     self.btree = btree
     self.keys = new_array(self.btree.b)
     self.children = new_int_array(self.btree.b + 1, -1)
     self.id = self.btree.bs.place_block(self)
コード例 #25
0
 def _initialize(self):
     self.adj = new_array(self.n)
     for i in range(self.n):
         self.adj[i] = ArrayStack()
コード例 #26
0
ファイル: algorithms.py プロジェクト: GaganJotSingh/ods
def dfs(g, r):
    c = new_array(g.n)
    _dfs(g, r, c)
コード例 #27
0
 def __init__(self, x, h):
     self.x = x
     self.next = new_array(h+1)
コード例 #28
0
ファイル: binarytrie.py プロジェクト: GaganJotSingh/ods
 def __init__(self):
     self.child  = new_array(2)
     self.jump = None
     self.parent = None
     self.x = None
コード例 #29
0
 def __init__(self, b):
     super(SEList.BDeque, self).__init__()
     self.a = new_array(b + 1)
コード例 #30
0
 def _resize(self):
     b = new_array(max(1, 2 * self.n))
     b[0:self.n] = self.a[0:self.n]
     self.a = b
コード例 #31
0
ファイル: skiplistlist.py プロジェクト: GaganJotSingh/ods
 def __init__(self, x, h):
     self.x = x
     self.next = new_array(h+1)
     self.length = numpy.ones(h+1, dtype=int)
コード例 #32
0
ファイル: skiplistsset.py プロジェクト: GaganJotSingh/ods
 def _initialize(self):
     self.h = 0
     self.n = 0
     self.sentinel = self._new_node(None, 32)
     self.stack = new_array(self.sentinel.height()+1)
コード例 #33
0
 def _initialize(self):
     self.a = new_array(1)
     self.j = 0
     self.n = 0
コード例 #34
0
ファイル: arrayqueue.py プロジェクト: patmorin/ods
 def _initialize(self):
     self.a = new_array(1)
     self.j = 0
     self.n = 0
コード例 #35
0
 def __init__(self):
     self.a = new_array(1)  #New array is created
     self.n = 0  #Number of elements in the array
     self.capacity = len(self.a)  #The capacity of the array
コード例 #36
0
ファイル: rootisharraystack.py プロジェクト: mando20/ods
 def grow(self):
     self.blocks.append(new_array(self.blocks.size()+1))
コード例 #37
0
ファイル: binaryheap.py プロジェクト: vivekasingh/ods
 def resize(self):
     b = new_array(max(2 * self.n, 1))
     for i in range(self.n):
         b[i] = self.a[i]
     self.a = b
コード例 #38
0
 def __init__(self):
     self.a = new_array(1)
     self.n = 0
     self.capacity = len(self.a)
コード例 #39
0
def dfs(g, r):
    c = new_array(g.n)
    _dfs(g, r, c)
コード例 #40
0
 def _initialize(self):
     self.h = 0
     self.n = 0
     self.sentinel = self._new_node(None, 32)
     self.stack = new_array(self.sentinel.height()+1)
コード例 #41
0
 def __init__(self):
     self.child = new_array(2)
     self.jump = None
     self.parent = None
     self.x = None
コード例 #42
0
ファイル: selist.py プロジェクト: rugbyprof/ods
 def __init__(self, b):
     super(SEList.BDeque, self).__init__()
     self.a = new_array(b+1)
コード例 #43
0
ファイル: linearhashtable.py プロジェクト: rugbyprof/ods
 def initialize(self):
     self.d = 1
     self.t = new_array((1<<self.d))
     self.q = 0
     self.n = 0
コード例 #44
0
 def _resize(self):
     b = new_array(max(1, 2 * self.n))
     for k in range(self.n):
         b[k] = self.a[(self.j + k) % len(self.a)]
     self.a = b
     self.j = 0
コード例 #45
0
ファイル: arraystack.py プロジェクト: rugbyprof/ods
 def _resize(self):
     b = new_array(max(1, 2 * self.n))
     for i in range(self.n):
         b[i] = self.a[i]
     self.a = b