FactorCache::FactorCache Class Reference

Inheritance diagram for FactorCache::FactorCache:

Inheritance graph
[legend]
Collaboration diagram for FactorCache::FactorCache:

Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def type
def __str__
def addString
def addValue
def verify


Detailed Description

Cache factor lists in a dictionary.
Key is the value of the number.
Value is the list of the numbers' factors (.

Definition at line 11 of file FactorCache.py.


Member Function Documentation

def FactorCache::FactorCache::__init__ (   self,
  saver = None 
)

Reimplemented from Cache::Cache.

Definition at line 19 of file FactorCache.py.

00019                                       :
00020 
00021         Cache.Cache.__init__( self, saver )
00022         
    def type( self ):

def FactorCache::FactorCache::__str__ (   self  ) 

Definition at line 27 of file FactorCache.py.

00027                        :
00028 
00029         answer = ""
00030         keys = self.sortedkeys( )
00031         for key in keys:
00032             factors = self._dict[ key ]
00033             answer += "%s %s\n" % ( key, factors )
00034 
00035         if answer == "":
00036             answer = "<FactorCache.FactorCache instance>"
00037 
00038         return answer
00039 
    def addString( self, line ):

def FactorCache::FactorCache::addString (   self,
  line 
)

Definition at line 40 of file FactorCache.py.

00040                                :
00041 
00042         tokens = re.split( "[()]+", line )
00043         value = mpz( tokens[ 0 ] )
00044         factors = Factors.FromString( tokens[ 1 ]  )
00045         self.addValue( value, factors, False )
00046 
    def addValue( self, value, factors, saver = True ):

def FactorCache::FactorCache::addValue (   self,
  value,
  factors,
  saver = True 
)

Definition at line 47 of file FactorCache.py.

00047                                                       :
00048 
00049         if self.verify( value, factors ):
00050             if not self._dict.has_key( value ):
00051                 self.at_put( value, factors )
00052                 if saver:
00053                     globals.Saver.newFactor( )
00054 
00055         return
00056 
    def verify( self, value, factors ):

def FactorCache::FactorCache::type (   self  ) 

Reimplemented from Cache::Cache.

Definition at line 23 of file FactorCache.py.

00023                     :
00024 
00025         return "FactorCache"
00026 
    def __str__( self ):

def FactorCache::FactorCache::verify (   self,
  value,
  factors 
)

Definition at line 57 of file FactorCache.py.

00057                                       :
00058 
00059         magnitude = factors.magnitude( )
00060         if value == magnitude:
00061             return True
00062         else:
00063             print "FactorCache error:"
00064             print "  %s" % value
00065             print "  %s" % factors
00066             pydb.debugger( )
00067             return False
00068 
if __name__ == '__main__':


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

Generated on Sun Mar 22 09:59:14 2009 for Multiperfect Number Generator by  doxygen 1.5.8