本文整理汇总了Python中LinkedList.LinkedList.getLastItemOf方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.getLastItemOf方法的具体用法?Python LinkedList.getLastItemOf怎么用?Python LinkedList.getLastItemOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.getLastItemOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Term
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import getLastItemOf [as 别名]
class Term():
def __init__(self, term):
self.term = term;
self.docs = LinkedList();
self.count = 1;
self._iterator = None;
self._temp = None;
def __str__(self):
return "Term: " + self.term + ', count:' + str(self.count) + self.docs.toString(',');
def __lt__(self, other):
return self.term < other.term;
def __eq__(self, other):
return self.term == other.term;
def reset(self):
self.docs.reset();
self._iterator = None;
def insertDoc(self, doc, line):
obj = IndexList.Doc(doc);
current = self.docs.getLastItemOf(obj);
if current:
current.count += 1;
else:
self.docs.insertSorted(obj);
current = obj;
current.insertLine(line);
def __iter__(self):
return self;
def next(self):
if self._temp is None:
if self.terms is None: raise StopIteration
self._temp = self.terms;
if self._temp._currentNode is None: raise StopIteration
value = self._temp._currentNode.value;
self._temp._currentNode = self._temp._currentNode.next;
return value;
def __iter__(self):
return self;
def next(self):
if self._iterator is None:
if self.docs._head is None: raise StopIteration
self._iterator = self.docs._head;
return self._iterator.value;
self._iterator = self._iterator.next;
if self._iterator is None: raise StopIteration
return self._iterator.value;
示例2: IndexList
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import getLastItemOf [as 别名]
class IndexList():
def __init__(self):
self.objs = LinkedList();
self._iterator = None;
def __str__(self):
return self.objs.toString('\n');
def reset(self):
self.objs.reset();
self._iterator = None;
def insert(self, string1, string2, string3):
obj = IndexList.Term(string1);
current = self.objs.getLastItemOf(obj);
if current:
current.count += 1;
else:
self.objs.insertSorted(obj);
current = obj;
current.insertDoc(string2, string3);
return current;
def __iter__(self):
return self;
def next(self):
if self._iterator is None:
if self.objs._head is None: raise StopIteration
self._iterator = self.objs._head;
return self._iterator.value;
self._iterator = self._iterator.next;
if self._iterator is None: raise StopIteration
return self._iterator.value;
class Term():
def __init__(self, term):
self.term = term;
self.docs = LinkedList();
self.count = 1;
self._iterator = None;
self._temp = None;
def __str__(self):
return "Term: " + self.term + ', count:' + str(self.count) + self.docs.toString(',');
def __lt__(self, other):
return self.term < other.term;
def __eq__(self, other):
return self.term == other.term;
def reset(self):
self.docs.reset();
self._iterator = None;
def insertDoc(self, doc, line):
obj = IndexList.Doc(doc);
current = self.docs.getLastItemOf(obj);
if current:
current.count += 1;
else:
self.docs.insertSorted(obj);
current = obj;
current.insertLine(line);
def __iter__(self):
return self;
def next(self):
if self._temp is None:
if self.terms is None: raise StopIteration
self._temp = self.terms;
if self._temp._currentNode is None: raise StopIteration
value = self._temp._currentNode.value;
self._temp._currentNode = self._temp._currentNode.next;
return value;
def __iter__(self):
return self;
def next(self):
if self._iterator is None:
if self.docs._head is None: raise StopIteration
self._iterator = self.docs._head;
return self._iterator.value;
self._iterator = self._iterator.next;
if self._iterator is None: raise StopIteration
return self._iterator.value;
class Doc():
def __init__(self, doc):
self.doc = doc;
self.lines = LinkedList();
self.count = 1;
self._iterator = None;
self.documentFrequency = None;
def reset(self):
self.lines.reset();
self._iterator = None;
def __str__(self):
return '\n\t' + str(self.doc) + ', count:' + str(self.count) + self.lines.toString(',');
def __lt__(self, other):
return self.doc < other.doc;
def __eq__(self, other):
return self.doc == other.doc;
def insertLine(self, line):
line = IndexList.Line(int(line));
self.lines.insertSorted(line);
#.........这里部分代码省略.........