package com.nailabs.abac.trust; import edu.stanford.peer.rbtm.credential.*; import java.util.*; /** * Place holder for sets of nodes. An internal index keeps track of nodes * as new ones are added to the set. Future versions may implement a sorting * algorithm for nodes. */ public class TTGNodeSet extends HashMap { /** index of nodes that have been enqueued for processing */ protected LinkedList index = new LinkedList(); /** add a single trust target graph node to the set */ public boolean add(TTGNode node) { boolean isNew = containsValue(node); if(node == null) { System.out.println("Attempting to add null node!!"); return false; } if(isNew) { System.out.println("Duplicate node in set. " + node.getGoal()); index.add(node); } put(node.getGoal(), node); return isNew; } /** adds a set of nodes to the set */ public boolean addAll(TTGNodeSet set) { boolean result = false; Iterator i = set.values().iterator(); while(i.hasNext()) { TTGNode node = (TTGNode)i.next(); result = (result || add(node)); } return result; } public Object getFirst() { return index.getFirst(); } public Object getLast() { return index.getLast(); } }