54 lines
1.4 KiB
Plaintext
54 lines
1.4 KiB
Plaintext
' FB 1.05.0 Win64
|
|
|
|
#Include "queue_rosetta.bi"
|
|
|
|
Type Cat
|
|
name As String
|
|
age As Integer
|
|
Declare Constructor
|
|
Declare Constructor(name_ As string, age_ As integer)
|
|
Declare Operator Cast() As String
|
|
end type
|
|
|
|
Constructor Cat '' default constructor
|
|
End Constructor
|
|
|
|
Constructor Cat(name_ As String, age_ As Integer)
|
|
name = name_
|
|
age = age_
|
|
End Constructor
|
|
|
|
Operator Cat.Cast() As String
|
|
Return "[" + name + ", " + Str(age) + "]"
|
|
End Operator
|
|
|
|
Declare_Queue(Cat) '' expand Queue type for Cat instances
|
|
|
|
Dim CatQueue As Queue(Cat)
|
|
|
|
Var felix = Cat("Felix", 8)
|
|
Var sheba = Cat("Sheba", 4)
|
|
Var fluffy = Cat("Fluffy", 2)
|
|
With CatQueue '' push these Cat instances into the Queue
|
|
.push(felix)
|
|
.push(sheba)
|
|
.push(fluffy)
|
|
End With
|
|
Print "Number of Cats in the Queue :" ; CatQueue.count
|
|
Print "Capacity of Cat Queue :" ; CatQueue.capacity
|
|
Print "Front Cat : "; CatQueue.front
|
|
CatQueue.pop()
|
|
Print "Front Cat now : "; CatQueue.front
|
|
Print "Number of Cats in the Queue :" ; CatQueue.count
|
|
CatQueue.pop()
|
|
Print "Front Cat now : "; CatQueue.front
|
|
Print "Number of Cats in the Queue :" ; CatQueue.count
|
|
Print "Is Queue empty now : "; CatQueue.empty
|
|
catQueue.pop()
|
|
Print "Number of Cats in the Queue :" ; CatQueue.count
|
|
Print "Is Queue empty now : "; CatQueue.empty
|
|
catQueue.pop()
|
|
Print
|
|
Print "Press any key to quit"
|
|
Sleep
|