@Override public double getValue(int pos) { checkPos(pos); double result = defaultValue; if (data.containsKey(pos)) { result = data.get(pos); } return result; }
/** * Returns all Attributes that one or more of the given nodes have values for. */ public static String[] getNodeAttributes(int[] node_indices) { IntArrayList att_keys = new IntArrayList(); getNodeAttributeIDToAttributeValuesMap().keys(att_keys); HashSet attributes = new HashSet(); for (int k = 0; k < att_keys.size(); ++k) { for (int i = 0; i < node_indices.length; ++i) { if (att_keys.get(k) == DOUBLE_TYPE) { OpenIntDoubleHashMap n2v = (OpenIntDoubleHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_keys.get(k)); if (n2v.containsKey(node_indices[i])) { attributes.add(getNodeAttIDToAttNameMap().get(att_keys.get(k))); // don't look at anymore nodes i = node_indices.length; } } else { OpenIntObjectHashMap n2v = (OpenIntObjectHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_keys.get(k)); if (n2v.containsKey(node_indices[i])) { attributes.add(getNodeAttIDToAttNameMap().get(att_keys.get(k))); // don't look at anymore nodes i = node_indices.length; } } } } return (String[]) attributes.toArray(new String[] { }); }
/** * DOCUMENT ME! * * @param node_index DOCUMENT ME! * @param attribute DOCUMENT ME! * * @return DOCUMENT ME! */ public static double getNodeAttributeDoubleValue(int node_index, String attribute) { int att_id = getNodeAttributeID(attribute); if (att_id < 0) return Double.NaN; int att_type = getNodeAttIDToAttTypeMap().get(att_id); if (att_type == DOUBLE_TYPE) { OpenIntObjectHashMap a2v = getNodeAttributeIDToAttributeValuesMap(); OpenIntDoubleHashMap n2v = (OpenIntDoubleHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_id); if (n2v == null) { CyLogger.getLogger().info("Internal error: Unable to get node attribute id map"); return Double.NaN; } if (n2v.containsKey(node_index)) return n2v.get(node_index); // return ( ( OpenIntDoubleHashMap )getNodeAttributeIDToAttributeValuesMap().get( att_id )).get( node_index ); } return Double.NaN; }
/** * DOCUMENT ME! * * @param node DOCUMENT ME! * @param attribute DOCUMENT ME! * * @return DOCUMENT ME! */ public static double getNodeAttributeDoubleValue(Node node, String attribute) { int att_id = getNodeAttributeID(attribute); if (att_id < 0) return Double.NaN; int node_index = node.getRootGraphIndex(); int att_type = getNodeAttIDToAttTypeMap().get(att_id); if (att_type == DOUBLE_TYPE) { OpenIntObjectHashMap a2v = getNodeAttributeIDToAttributeValuesMap(); OpenIntDoubleHashMap n2v = (OpenIntDoubleHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_id); if (n2v == null) { CyLogger.getLogger().info("Internal error: Unable to get node attribute id map"); return Double.NaN; } if (n2v.containsKey(node_index)) return n2v.get(node_index); // return ( ( OpenIntDoubleHashMap )getNodeAttributeIDToAttributeValuesMap().get( att_id )).get( node_index ); } return Double.NaN; }