All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
SortModuleTimes.MaxItemLengthsClass Class Reference

Public Member Functions

def __init__
 
def add
 
def __len__
 
def __iter__
 
def __getitem__
 

Public Attributes

 maxlength
 

Detailed Description

A list with the maximum length of items seen.

Facilitates the correct sizing of a table in text mode.

When a list of strings is add()ed, for each position in the list the length
of the string in that position is compared to the maximum one seen so far in
that position, and that maximum value is updated if proper.

Definition at line 617 of file SortModuleTimes.py.

Constructor & Destructor Documentation

def SortModuleTimes.MaxItemLengthsClass.__init__ (   self,
  n = 0 
)

Definition at line 626 of file SortModuleTimes.py.

627  def __init__(self, n = 0):
628  self.maxlength = [ None ] * n

Member Function Documentation

def SortModuleTimes.MaxItemLengthsClass.__getitem__ (   self,
  index 
)

Definition at line 644 of file SortModuleTimes.py.

645  def __getitem__(self, index): return self.maxlength[index]
646 
647 # class MaxItemLengthsClass
648 
def SortModuleTimes.MaxItemLengthsClass.__iter__ (   self)

Definition at line 643 of file SortModuleTimes.py.

def __iter__(self): return iter(self.maxlength)
def SortModuleTimes.MaxItemLengthsClass.__len__ (   self)

Definition at line 642 of file SortModuleTimes.py.

def __len__(self): return len(self.maxlength)
def SortModuleTimes.MaxItemLengthsClass.add (   self,
  items 
)

Definition at line 629 of file SortModuleTimes.py.

630  def add(self, items):
631  for iItem, item in enumerate(items):
632  try:
633  maxlength = self.maxlength[iItem]
634  except IndexError:
635  self.maxlength.extend([ None ] * (iItem + 1 - len(self.maxlength)))
636  maxlength = None
637  #
638  itemlength = len(str(item))
639  if maxlength < itemlength: self.maxlength[iItem] = itemlength
# for
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69

Member Data Documentation

SortModuleTimes.MaxItemLengthsClass.maxlength

Definition at line 627 of file SortModuleTimes.py.


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