本文整理匯總了Python中LinkedList.LinkedList.reset方法的典型用法代碼示例。如果您正苦於以下問題:Python LinkedList.reset方法的具體用法?Python LinkedList.reset怎麽用?Python LinkedList.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.reset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Doc
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import reset [as 別名]
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);
def __iter__(self):
return self;
def next(self):
if self._iterator is None:
if self.lines._head is None: raise StopIteration
self._iterator = self.lines._head;
return self._iterator.value;
self._iterator = self._iterator.next;
if self._iterator is None: raise StopIteration
return self._iterator.value;
示例2: Term
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import reset [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;
示例3: IndexList
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import reset [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);
#.........這裏部分代碼省略.........