commit 595f08259cfd44f1a6faf1a169735f6f452904ce

Refs: candlepin-0.7.10-1-1-g595f082
Author:     James Bowes <jbowes@redhat.com>
AuthorDate: Wed Sep 19 17:22:36 2012 -0300
Commit:     James Bowes <jbowes@redhat.com>
CommitDate: Wed Sep 19 17:22:36 2012 -0300

    certv3: sort path names alphabetically

    By sorting the child paths of a node alphabetically, clients can do a
    binary search for the node they want, rather than having to iterate over
    all children.
This commit is contained in:
Vincent Batts 2012-10-04 10:31:46 -04:00
parent 721355396c
commit 9520047496
2 changed files with 7 additions and 1 deletions

View file

@ -15,7 +15,7 @@
package com.redhat.trie;
public class NodePair {
public class NodePair implements Comparable {
private String name;
private PathNode connection;
@ -39,5 +39,9 @@ public class NodePair {
public String toString() {
return "Name: " + name + ", Connection: " + connection.getId();
}
public int compareTo(Object other) {
return this.name.compareTo(((NodePair) other).name);
}
}

View file

@ -17,6 +17,7 @@ package com.redhat.trie;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
public class PathNode {
private long id = 0;
@ -48,6 +49,7 @@ public class PathNode {
}
public List<NodePair> getChildren() {
Collections.sort(this.children);
return this.children;
}