Search in sources :

Example 6 with SET

use of org.mozilla.jss.asn1.SET in project AlgorithmsSolutions by Allenskoo856.

the class Concordance method main.

public static void main(String[] args) {
    ST<String, SET<Integer>> st = new ST<>();
    In in = new In(args[0]);
    String[] words = in.readAllStrings();
    for (int i = 0; i < words.length; i++) {
        String word = words[i];
        if (!st.contains(word)) {
            st.put(word, new SET<Integer>());
        }
        st.get(word).add(i);
    }
    while (!StdIn.isEmpty()) {
        String query = StdIn.readString();
        if (st.contains(query)) {
            for (int pos : st.get(query)) {
                for (int i = Math.max(0, pos - CONTEXT + 1); i < pos; i++) {
                    System.out.print(words[i] + " ");
                }
                System.out.print("\"" + words[pos] + "\"");
                for (int i = pos + 1; i < Math.min(words.length, pos + CONTEXT); i++) {
                    System.out.print(" " + words[i]);
                }
                System.out.println();
            }
        }
    }
}
Also used : ST(edu.princeton.cs.algs4.ST) SET(edu.princeton.cs.algs4.SET) StdIn(edu.princeton.cs.algs4.StdIn) In(edu.princeton.cs.algs4.In)

Aggregations

In (edu.princeton.cs.algs4.In)3 SET (edu.princeton.cs.algs4.SET)3 StdIn (edu.princeton.cs.algs4.StdIn)3 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)3 SET (org.mozilla.jss.asn1.SET)3 ST (edu.princeton.cs.algs4.ST)2 ASN1Value (org.mozilla.jss.asn1.ASN1Value)2 BMPString (org.mozilla.jss.asn1.BMPString)2 OCTET_STRING (org.mozilla.jss.asn1.OCTET_STRING)2 SafeBag (org.mozilla.jss.pkcs12.SafeBag)2 AMPassword (com.sun.identity.security.keystore.AMPassword)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 MessageDigest (java.security.MessageDigest)1 ANY (org.mozilla.jss.asn1.ANY)1 AuthenticatedSafes (org.mozilla.jss.pkcs12.AuthenticatedSafes)1 PFX (org.mozilla.jss.pkcs12.PFX)1 Attribute (org.mozilla.jss.pkix.primitive.Attribute)1 Password (org.mozilla.jss.util.Password)1