Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
53
Task/Queue-Definition/FreeBASIC/queue-definition-2.basic
Normal file
53
Task/Queue-Definition/FreeBASIC/queue-definition-2.basic
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue