task 1.1. first try
This commit is contained in:
parent
dbc3ae50fe
commit
cdc81b5dae
@ -1,5 +1,6 @@
|
||||
import exceptions._
|
||||
import scala.collection.mutable
|
||||
import scala.collection.mutable._
|
||||
|
||||
object TransactionStatus extends Enumeration {
|
||||
val SUCCESS, PENDING, FAILED = Value
|
||||
@ -10,21 +11,21 @@ class TransactionQueue {
|
||||
// TODO
|
||||
// project task 1.1
|
||||
// Add datastructure to contain the transactions
|
||||
|
||||
var queue: Queue[Transaction] = Queue()
|
||||
// Remove and return the first element from the queue
|
||||
def pop: Transaction = ???
|
||||
def pop: Transaction = {queue.synchronized(queue.dequeue())}
|
||||
|
||||
// Return whether the queue is empty
|
||||
def isEmpty: Boolean = ???
|
||||
def isEmpty: Boolean = {queue.synchronized(queue.isEmpty())}
|
||||
|
||||
// Add new element to the back of the queue
|
||||
def push(t: Transaction): Unit = ???
|
||||
def push(t: Transaction): Unit = {queue.synchronized(queue.push(t))}
|
||||
|
||||
// Return the first element from the queue without removing it
|
||||
def peek: Transaction = ???
|
||||
def peek: Transaction = {queue.synchronized(queue.front())}
|
||||
|
||||
// Return an iterator to allow you to iterate over the queue
|
||||
def iterator: Iterator[Transaction] = ???
|
||||
def iterator: Iterator[Transaction] = {queue.synchronized(queue.iterator())}
|
||||
}
|
||||
|
||||
class Transaction(val transactionsQueue: TransactionQueue,
|
||||
|
Loading…
Reference in New Issue
Block a user