Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
50
Task/Queue-Definition/Nanoquery/queue-definition.nanoquery
Normal file
50
Task/Queue-Definition/Nanoquery/queue-definition.nanoquery
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
class FIFO
|
||||
declare contents
|
||||
|
||||
// define constructors for FIFO objects
|
||||
def FIFO()
|
||||
this.contents = {}
|
||||
end
|
||||
def FIFO(contents)
|
||||
this.contents = contents
|
||||
end
|
||||
|
||||
// define methods for this class
|
||||
def push(value)
|
||||
contents.append(value)
|
||||
end
|
||||
def pop()
|
||||
if !this.empty()
|
||||
value = contents[len(contents) - 1]
|
||||
contents.remove(len(contents) - 1)
|
||||
return value
|
||||
else
|
||||
// we could throw our own exception here but
|
||||
// we'll return null instead
|
||||
return null
|
||||
end
|
||||
end
|
||||
def length()
|
||||
return len(contents)
|
||||
end
|
||||
def extend(itemlist)
|
||||
contents += itemlist
|
||||
end
|
||||
def empty()
|
||||
return len(contents) = 0
|
||||
end
|
||||
|
||||
// define operators for this class
|
||||
def toString()
|
||||
return str(contents)
|
||||
end
|
||||
def operator+(other)
|
||||
return this.contents + other.contents
|
||||
end
|
||||
def operator*(n)
|
||||
return this.contents * n
|
||||
end
|
||||
def operator=(other)
|
||||
return this.contents = other.contents
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue