use of com.jimmysun.algorithms.chapter2_1.Transaction in project algorithms-sedgewick-wayne by reneargento.
the class Exercise17 method readAllTransactions.
public static Transaction[] readAllTransactions(String fileName) {
In in = new In(fileName);
Queue<Transaction> queue = new Queue<>();
while (!in.isEmpty()) {
queue.enqueue(new Transaction(in.readLine()));
}
int queueSize = queue.size();
Transaction[] transactions = new Transaction[queueSize];
for (int i = 0; i < queueSize; i++) {
transactions[i] = queue.dequeue();
}
return transactions;
}
Aggregations