com.intel.jndn.utils.NameTree Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jndn-utils Show documentation
Show all versions of jndn-utils Show documentation
Collection of tools to simplify synchronous and asynchronous data transfer over the NDN network
/*
* jndn-utils
* Copyright (c) 2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
* version 3, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*/
package com.intel.jndn.utils;
import net.named_data.jndn.Name;
import java.util.Collection;
import java.util.Optional;
/**
* Represent a tree of nodes, branching based on their component values
*
* @author Andrew Brown, [email protected]
*/
public interface NameTree {
/**
* @return the full name leading from the root of the tree to this node
*/
Name fullName();
/**
* @return the last component identifying this node; e.g. if the {@link #fullName()} is {@code /a/b/c} for this node,
* this method must return {@code c}
*/
Name.Component lastComponent();
/**
* @return the optional content stored at this location in the tree
*/
Optional content();
/**
* @return the children of this node or an empty collection
*/
Collection> children();
/**
* @return the parent of this node; note that calling this on the root node will return {@code null}
*/
NameTree parent();
/**
* @param name the full name leading to the location in the tree; if intervening nodes do not yet exist, they will be
* created
* @param content the content to store at this location; this may overwrite previously existing content, much like a
* {@link java.util.Map}
* @return a reference to the node inserted
*/
NameTree insert(Name name, T content);
/**
* @param query the name to use as a path through the tree
* @return an optional node; if there is no node at the end of the query, the {@link Optional} will be empty
*/
Optional> find(Name query);
/**
* @param name the name to use as a path through the tree
* @return the removed node or an empty {@link Optional} if the node was not found
*/
Optional> delete(Name name);
/**
* @return the count of all nodes in the tree below this one that are non-empty (e.g. have some content)
*/
int count();
/**
* Remove all nodes beneath this one; will have no effect on a leaf node
*/
void clear();
}