aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913/Java/project3/project3_strap012.java
blob: c8a471943433e2da78e01df82c0611aabe1ff5ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package project3;

class AnagramTree {
    private TreeNode head;
    private class TreeNode {
        private byte[] summary;
        private WordNode words;
        private TreeNode left, right;
        private TreeNode(String word) {
            summary = stringToSummary(word);
            // words = new WordNode(word);
            left = null; right = null;
        }
    }

    private class WordNode {
        private String word;
        private WordNode next;
        private WordNode(String word) {
            this.word = word;
            next = null;
        }
    }

    public AnagramTree() {
        head = new TreeNode("e");
    }

    public void add (String word) {

    }

    public void anagrams() {

    }
    
    private int compareSummaries(byte[] left, byte[] right) {
        for (int i = 0; i < 25; i++) {
            if (left[i] != right[i]) {
                return left[i] - right[i];
            }
        }
        return 0;
    }

    private byte[] stringToSummary(String word) {
        byte[] temp = new byte[26];
        for (byte i = 0; i < word.length(); i++) {
            temp[i] = (byte) (word.charAt(i) - ('a' + i));
        }
        return temp;
    }
}