X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Futil%2Fdata%2FNode.java;h=950ed990874b31058b57f3b9a426904fba065808;hb=4fa04bea2bcb171075208b7fe231dffc99c296d9;hp=3ba6004883c3f6b7d97b99c73dd900538e13cf9c;hpb=364659907c0364092e78824d3eea4a13fecd831b;p=jSite2.git diff --git a/src/net/pterodactylus/util/data/Node.java b/src/net/pterodactylus/util/data/Node.java index 3ba6004..950ed99 100644 --- a/src/net/pterodactylus/util/data/Node.java +++ b/src/net/pterodactylus/util/data/Node.java @@ -1,6 +1,7 @@ package net.pterodactylus.util.data; +import java.util.Comparator; import java.util.Iterator; /** @@ -12,7 +13,7 @@ import java.util.Iterator; * @param * The type of the element to store */ -public interface Node extends Iterable> { +public interface Node> extends Iterable>, Comparable> { /** * Returns the parent node of the node. @@ -54,6 +55,17 @@ public interface Node extends Iterable> { public Node getChild(int index); /** + * Returns the direct child node that contains the given element. + * + * @param element + * The element + * @return The direct child node containing the given element, or + * null if this node does not have a child node + * containing the given element + */ + public Node getChild(E element); + + /** * Returns whether the given node is a direct child of this node. * * @param childNode @@ -61,7 +73,18 @@ public interface Node extends Iterable> { * @return true if the given node is a direct child of this * node, false otherwise */ - public boolean hasChildNode(Node childNode); + public boolean hasChild(Node childNode); + + /** + * Returns whether this node contains a child node containing the given + * element. + * + * @param element + * The element + * @return true if this node contains a direct child node + * containing the given element, false otherwise + */ + public boolean hasChild(E element); /** * Returns the index of the given child node. @@ -110,6 +133,11 @@ public interface Node extends Iterable> { public void removeChild(int childIndex); /** + * Removes all children from this node. + */ + public void removeAllChildren(); + + /** * {@inheritDoc} */ public Iterator> iterator(); @@ -125,4 +153,17 @@ public interface Node extends Iterable> { */ public Node findChild(E element); + /** + * Sorts all children according to their natural order. + */ + public void sortChildren(); + + /** + * Sorts all children with the given comparator. + * + * @param comparator + * The comparator used to sort the children + */ + public void sortChildren(Comparator> comparator); + } \ No newline at end of file