當前位置: 首頁>>代碼示例>>Python>>正文


Python LinkedList.__str__方法代碼示例

本文整理匯總了Python中LinkedList.LinkedList.__str__方法的典型用法代碼示例。如果您正苦於以下問題:Python LinkedList.__str__方法的具體用法?Python LinkedList.__str__怎麽用?Python LinkedList.__str__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LinkedList.LinkedList的用法示例。


在下文中一共展示了LinkedList.__str__方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testLinkedList

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import __str__ [as 別名]
def testLinkedList():
    ll = LinkedList()
    while True:
        print ("Choose operation: ")
        print (" 1 - Add\n",
               "2 - Remove\n",
               "3 - Search\n",
               "4 - Size\n",
               "5 - Exit\n")
        choice = input()
        if choice == '1':
            ll = addll(ll)
            ll.__str__()
        elif choice == '2':
            ll == removell(ll)
            ll.__str__()
        elif choice == '3':
            searchKey(ll)
            ll.__str__()
        elif choice == '4':
            size(ll)
            ll.__str__()
        elif choice == '5':
            break
        else:
            print ("BAD Choice! Choose from 1 to 4 numbers")
開發者ID:mbhushan,項目名稱:ps-algods-py,代碼行數:28,代碼來源:LinkedListClient.py

示例2: __init__

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import __str__ [as 別名]
class Queue:
    def __init__(self):
        self.__elements = LinkedList()

    # Adds an element to this queue
    def enqueue(self, e):
        self.__elements.add(e)
    
    # Removes an element from this queue
    def dequeue(self):
        if self.getSize() == 0:
            return None
        else:
            return self.__elements.removeAt(0)
    
    # Return the size of the queue
    def getSize(self):
        return self.__elements.getSize()
    
    # Returns a string representation of the queue
    def __str__(self):
        return self.__elements.__str__()

    # Return true if queue is empty 
    def isEmpty(self):
        return self.getSize() == 0
開發者ID:EthanSeaver,項目名稱:Python-Projects,代碼行數:28,代碼來源:Queue.py

示例3: comment

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import __str__ [as 別名]
        comment("OK -> " + test_name)
        grade(points['ll_1e_getsize'])
except:
    e = sys.exc_info()[1]
    comment("FAIL -> " + test_name + "\n" + str(e))
    grade(0)


# Check one element list - __str__()


try:
    test_name = 'LinkedList con un elemento: __str__'
    l = LinkedList()
    l.insertAfter(17)
    if type(str(l)) == types.StringType and not l.__str__().count('17') != 1:
        comment("OK -> " + test_name)
        grade(points['ll_1e_str'])
    else:
        comment("FAIL -> " + test_name +"\n __str__ debe devolver una lista de caracteres (string) con los elementos de la lista")
        grade(0)
except:
    e = sys.exc_info()[1]
    comment("FAIL -> " + test_name + "\n" + str(e))
    grade(0)


# Check one element list - remove()


try:
開發者ID:emiliogq,項目名稱:pyrobot,代碼行數:33,代碼來源:joc_proves_LinkedList.py

示例4: LinkedList

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import __str__ [as 別名]
from LinkedList import LinkedList

# Test cases for LinkedList
linklist = LinkedList()
linklist2 = LinkedList()
linklist.add(1)
print(linklist.__str__())
linklist.add(2)
print(linklist.__str__())
linklist.add(3)
print(linklist.__str__())
linklist.add(4)
print(linklist.__str__())
linklist.remove(2)
print(linklist.__str__())
linklist.remove(1)
linklist.remove(6)
print(linklist.contains(1))
print(linklist.__str__())
print(linklist.size)
開發者ID:NateRiehl,項目名稱:Python-Data-Structures,代碼行數:22,代碼來源:TestLinkedList.py


注:本文中的LinkedList.LinkedList.__str__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。