from Bag import Bag, BagIterator

def createIntBag():
    intBag=Bag()
    intBag.add(6)
    intBag.add(11)
    intBag.add(77)
    intBag.add(7)
    intBag.add(4)
    intBag.add(6)
    intBag.add(77)
    intBag.add(6)
    return intBag

def createStringBag():
    stringBag=Bag()
    stringBag.add("data")
    stringBag.add("structures")
    stringBag.add("and")
    stringBag.add("algorithms")
    stringBag.add("data")
    stringBag.add("data")
    stringBag.add("algorithms")
    return stringBag

def printBag(bag):
    it = bag.iterator()
    while it.valid():
        print(it.getCurrent())
        it.next()
    print("Over. Let's start again.")
    it.first()
    while it.valid():
        print(it.getCurrent())
        it.next()

def main():
    b1 = createIntBag()
    printBag(b1)
    print("No occurrences of 77: ", b1.nrOccurrences(77))
    b2 = createStringBag()
    printBag(b2)
    print("No occurrences of 'data': ", b2.nrOccurrences("data"))

if __name__ == "__main__":
    main()