-1
我需要類似的功能QListIterator如:
的next() - 在python發現ofcourse
peekNext()
以前的()
在QT中是否有類似QListIterator的Python類?
試圖尋找一個Python同級。
我需要類似的功能QListIterator如:
的next() - 在python發現ofcourse
peekNext()
以前的()
在QT中是否有類似QListIterator的Python類?
試圖尋找一個Python同級。
這就是我最後處理它的方式。 基於UserList類和hasNext()方法的類,用於檢查是否可以迭代前進,其他兩個用於獲取沒有索引增量的下一個值,並獲取具有索引增量的下一個值。 沒什麼特別的。
class BiDirectList(UserList.UserList):
"""
list with peek into next value method with no index increment
"""
def __init__(self, userList):
super(BiDirectList, self).__init__(userList)
self.next = 0
def hasNext(self):
# check if next value exists
try:
if self.data[self.next]: # data represent the list associated with the class object
return True
except IndexError:
return False
def getNext(self):
# gets next value and advance index in one
val = self.data[self.next]
self.next += 1
return val
def peekNext(self):
# gets next value if exists with no index increment
return self.data[self.next]
沒有。我的意思是一個用列表構造的類,並且有像next()和previous()和peeknext()這樣的函數,可以在不推進迭代器的情況下「偷看」下一個值。 http://qt-project.org/doc/qt-4.8/qlistiterator.html#details – 2014-11-05 18:14:05
我詢問之前,甚至在你的答案後,我可以猜測沒有在python中建立類。 我應該拿出一個我自己的班,或者採取別人的建議。 – 2014-11-05 18:20:24
請爲這樣的課程提供一個真實的用例。 – ekhumoro 2014-11-05 20:28:38