Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes
pymake.util.MostUsedCache Class Reference

List of all members.

Public Member Functions

def __init__
def setactive
def get
def verify
def debugitems

Public Attributes

 capacity
 cfunc
 vfunc
 d
 active

Detailed Description

Definition at line 104 of file util.py.


Constructor & Destructor Documentation

def pymake.util.MostUsedCache.__init__ (   self,
  capacity,
  creationfunc,
  verifyfunc 
)

Definition at line 105 of file util.py.

00105 
00106     def __init__(self, capacity, creationfunc, verifyfunc):
00107         self.capacity = capacity
00108         self.cfunc = creationfunc
00109         self.vfunc = verifyfunc
00110 
00111         self.d = {}
00112         self.active = [] # lazily sorted!


Member Function Documentation

Definition at line 147 of file util.py.

00147 
00148     def debugitems(self):
00149         l = [i.key for i in self.active]
00150         l.sort()
00151         return l
def pymake.util.MostUsedCache.get (   self,
  key 
)

Definition at line 125 of file util.py.

00125 
00126     def get(self, key):
00127         item = self.d.get(key, None)
00128         if item is None:
00129             item = _MostUsedItem(key)
00130             self.d[key] = item
00131         else:
00132             item.count += 1
00133 
00134         if item.o is not None and self.vfunc(key, item.o):
00135             return item.o
00136 
00137         item.o = self.cfunc(key)
00138         self.setactive(item)
00139         return item.o

Here is the call graph for this function:

Here is the caller graph for this function:

def pymake.util.MostUsedCache.setactive (   self,
  item 
)

Definition at line 113 of file util.py.

00113 
00114     def setactive(self, item):
00115         if item in self.active:
00116             return
00117 
00118         if len(self.active) == self.capacity:
00119             self.active.sort(key=lambda i: i.count)
00120             old = self.active.pop(0)
00121             old.o = None
00122             # print "Evicting %s" % old.key
00123 
00124         self.active.append(item)

Here is the caller graph for this function:

Definition at line 140 of file util.py.

00140 
00141     def verify(self):
00142         for k, v in self.d.iteritems():
00143             if v.o:
00144                 assert v in self.active
00145             else:
00146                 assert v not in self.active


Member Data Documentation

Definition at line 111 of file util.py.

Definition at line 106 of file util.py.

Definition at line 107 of file util.py.

Definition at line 110 of file util.py.

Definition at line 108 of file util.py.


The documentation for this class was generated from the following file: