Changeset 540

Show
Ignore:
Timestamp:
05/16/03 16:06:45 (6 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBFoundation/RBFoundation/Objects/NestedOperations.py

    r539 r540  
    3636 
    3737    name = '?' 
    38     _next = None 
     38    next = None 
    3939 
    4040    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    4545        if name is not None: 
    4646            self.name = name 
    47         self._next = next 
     47        if next is not None: 
     48            self.next = next 
     49            next.OnAddNestedOp(self) 
    4850        for n, v in kw.iteritems(): setattr(self, n, v) 
    4951 
     
    5254 
    5355    def __iter__(self): 
    54         next = self._next 
     56        next = self 
    5557        while next: 
    5658            yield next 
    57             next = next._next 
     59            next = next.next 
    5860 
    5961    def __getitem__(self, idx): 
     
    6365            try: 
    6466                itr = iter(self) 
    65                 for each in range(0, idx, -1): 
     67                for i in range(1, idx, -1): 
    6668                    result = itr.next() 
    6769                return result 
     
    7072        else: 
    7173            results = list(iter(self)) 
     74            results.reverse() 
    7275            return results[idx] 
     76 
     77    def OnAddNestedOp(self, nestedop): 
     78        pass 
    7379 
    7480#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    113119        assert op.result == shouldbe**2 
    114120        print op, op.value, op.result 
     121 
     122    firstop = result[-1] 
     123 
     124    assert firstop[-1] is result[-2] 
     125    assert firstop[-2] is result[-3] 
     126    assert firstop[-3] is result[-4] 
     127    assert firstop[-4] is result[-5] 
     128    assert firstop[-5] is result[-6] 
     129 
     130    assert firstop[0] is result[0] 
     131    assert firstop[1] is result[1] 
     132    assert firstop[2] is result[2] 
     133    assert firstop[3] is result[3] 
     134    assert firstop[4] is result[4] 
     135    assert firstop[5] is result[5]