Search in sources :

Example 71 with In

use of edu.princeton.cs.algs4.In 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;
}
Also used : Transaction(edu.princeton.cs.algs4.Transaction) In(edu.princeton.cs.algs4.In) Queue(edu.princeton.cs.algs4.Queue)

Example 72 with In

use of edu.princeton.cs.algs4.In in project algorithms-sedgewick-wayne by reneargento.

the class Exercise8 method main.

public static void main(String[] args) {
    In in = new In(args[0]);
    int[] values = in.readAllInts();
    StdOut.println(countEqualNumbers(values));
}
Also used : In(edu.princeton.cs.algs4.In)

Example 73 with In

use of edu.princeton.cs.algs4.In in project algorithms-sedgewick-wayne by reneargento.

the class Exercise2 method main.

public static void main(String[] args) {
    In in = new In(args[0]);
    int[] array = in.readAllInts();
    StdOut.println(count(array));
}
Also used : In(edu.princeton.cs.algs4.In)

Aggregations

In (edu.princeton.cs.algs4.In)71 StdIn (edu.princeton.cs.algs4.StdIn)10 HashSet (chapter3.section5.HashSet)5 ArrayList (java.util.ArrayList)5 SeparateChainingHashTable (chapter3.section4.SeparateChainingHashTable)4 ST (edu.princeton.cs.algs4.ST)4 Stopwatch (edu.princeton.cs.algs4.Stopwatch)4 Bag (com.jimmysun.algorithms.chapter1_3.Bag)3 Queue (edu.princeton.cs.algs4.Queue)3 SET (edu.princeton.cs.algs4.SET)3 RedBlackBST (chapter3.section3.RedBlackBST)2 Transaction (edu.princeton.cs.algs4.Transaction)2 Bag (chapter1.section3.Bag)1 Queue (chapter1.section3.Queue)1 Queue (com.jimmysun.algorithms.chapter1_3.Queue)1 Date (edu.princeton.cs.algs4.Date)1 Out (edu.princeton.cs.algs4.Out)1 File (java.io.File)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1