Esempio n. 1
0
 def exchangeValue(self,node,child):
     os.remove(self.dataList[node].filePath)
     tm_com.writeLines(self.dataList[node].filePath,self.dataList[child].lines)
     os.remove(self.dataList[child].filePath)
     tm_com.writeLines(self.dataList[child].filePath,self.dataList[node].lines)
     self.dataList[node] = tm_DividedFile(self.dataList[node].fileFolder,self.dataList[node].fileName)
     self.dataList[child] = tm_DividedFile(self.dataList[child].fileFolder,self.dataList[child].fileName)
Esempio n. 2
0
    def putMaxValueToNode(self,node,child):
        if debug:
            print '**************************'
            print 'exchange : ' + tm_com.line_feed
            print self.dataList[node]
            print self.dataList[child]
        nodeIndexFileSize = self.dataList[node].size
        childIndexFileSize = self.dataList[child].size
        biggerSize = max(nodeIndexFileSize,childIndexFileSize)
        allLines = []
        i = 0
        j = 0
        while i < self.dataList[node].size and j < self.dataList[child].size:
            if self.dataList[node].lines[i] < self.dataList[child].lines[j]:
                allLines.append(self.dataList[node].lines[i])
                i += 1
            else:
                allLines.append(self.dataList[child].lines[j])
                j += 1
        if i < nodeIndexFileSize:
            allLines.extend(self.dataList[node].lines[i:])
        else:
            allLines.extend(self.dataList[child].lines[j:])

        litterArray = allLines[:biggerSize]
        biggerArray = allLines[biggerSize:]
        os.remove(self.dataList[node].filePath)
        tm_com.writeLines(self.dataList[node].filePath,biggerArray)
        os.remove(self.dataList[child].filePath)
        tm_com.writeLines(self.dataList[child].filePath,litterArray)
        self.dataList[node] = tm_DividedFile(self.dataList[node].fileFolder,self.dataList[node].fileName)
        self.dataList[child] = tm_DividedFile(self.dataList[child].fileFolder,self.dataList[child].fileName)
        if debug:
            print 'after exchange: ' + tm_com.line_feed
            print self.dataList[node]
            print self.dataList[child]
            print '**************************'
Esempio n. 3
0
 def write(self):
     tm_com.writeLines(self.filePath,self.dataList)
     print 'write done : ' + self.name