@Override public synchronized boolean add(Long aLong) { version++; return map.put(aLong.intValue(), TRUE); }
public ColtIntegerHashSet(int initialCapacity) { this.map = new OpenIntObjectHashMap(initialCapacity); }
/** * DOCUMENT ME! * * @param ID DOCUMENT ME! * * @return DOCUMENT ME! */ public Filter getFilter(int ID) { return (Filter) ID2Filter.get(ID); }
/** * Trims the capacity of the receiver to be the receiver's current size. Releases any superfluous internal memory. An application * can use this operation to minimize the storage of the receiver. */ public void trimToSize() { // * 1.2 because open addressing's performance exponentially degrades // beyond that point // so that even rehashing the table can take very long int newCapacity = nextPrime((int) (1 + 1.2 * size())); if (table.length > newCapacity) { rehash(newCapacity); } }
public StructuresForConcordantShift(int hssSize) { substructureEdges = new ObjectArrayList(hssSize); hsIntersections = new OpenIntObjectHashMap(hssSize); coincidentIntersections = new ObjectArrayList(hssSize); for (int h = 0; h < hssSize; h++) { hsIntersections.put(h, new ObjectArrayList(8)); } } public void clear()
int i = indexOfInsertion(key); if (i<0) { //already contained i = -i -1; int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity); return put(key, value); int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity);
OpenIntObjectHashMap hsIntersections = new OpenIntObjectHashMap(); for (int h = 0; h < hss.size(); h++) OpenIntObjectHashMap nextTier = (OpenIntObjectHashMap) hs.getTiers().get(j2); ObjectArrayList intersections = new ObjectArrayList(); hsIntersections.put(h, intersections); for (int s = 0; s < nextTier.size(); s++) ICompactTripletsStructure lastTierStructure = ((IVertex) verticesFromLastTiers.get(h)).getCTS(); IVertex nextTierVertex = (IVertex) nextTier.values().get(s); ICompactTripletsStructure nextTierStructure = (ICompactTripletsStructure) nextTierVertex.getCTS().clone(); nextTierStructure.intersect(lastTierStructure); int intersectionsSize = ((ObjectArrayList) hsIntersections.get(0)).size(); for (int h = 0; h < hss.size(); h++) ObjectArrayList intersections = (ObjectArrayList) hsIntersections.get(h); ICompactTripletsStructure intersection = (ICompactTripletsStructure) intersections.get(v); coincidentIntersections.add(intersection);
boolean creatingNewIndex = !indexCache.containsKey(cacheKey); indexCache.put(cacheKey, index); index = (VarPairsIndex) indexCache.get(cacheKey);
private static void fillVerticesFromLastTier(ObjectArrayList hss, ObjectArrayList structures, OpenIntObjectHashMap verticesFromLastTiers) { IHyperStructure basicGraph = (IHyperStructure) hss.get(0); int tiersCount = basicGraph.getTiers().size(); // Pick any vertex from the last tier of each HS (with the same index for each HS) for(int h = 0; h < hss.size(); h++) { IHyperStructure hs = (IHyperStructure) hss.get(h); IVertex vertexFromTheLastTier = (IVertex) ((OpenIntObjectHashMap) hs.getTiers().get(tiersCount - 1)).values().get(0); verticesFromLastTiers.put(h, vertexFromTheLastTier); ICompactTripletsStructure structure = ((IVertex) verticesFromLastTiers.get(h)).getCTS(); structures.add(structure); } }
byte newState[] = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor); if (oldState[i] == FULL) { int element = oldTable[i]; int index = indexOfInsertion(element); newTable[index] = element; newValues[index] = oldValues[i];
/** * Add a filter and assign it the given unique ID */ public void addFilter(Filter filter, int ID) { if (ID < 0) { throw new IllegalArgumentException("ID must be greater than 0"); } if (ID2Filter.containsKey(ID)) { throw new IllegalArgumentException("ID map already contains that ID"); } ID2Filter.put(ID, filter); Filter2ID.put(filter, new Integer(ID)); filterList.add(filter); //System.out.println( "Filter list added: "+filter ); filter.getSwingPropertyChangeSupport().addPropertyChangeListener(this); notifyListeners(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, filterList.size(), filterList.size())); fireFilterEvent(); }
private static void assertIntersectionOfTierSubstructuresIsEmpty(IHyperStructure basicGraph, final int tierIndex) throws AssertionError { OpenIntObjectHashMap tierVertices = (OpenIntObjectHashMap) basicGraph.getTiers().get(tierIndex); if (tierVertices.size() == 1) { return; } ICompactTripletsStructure intersection = intersectAll(tierVertices.values()); if (!intersection.isEmpty()) { Helper.prettyPrint(intersection); throw new AssertionError("By the construction rules, intersection of substructure-vertices of a single tier should be an empty substructure"); } }
ObjectArrayList structures = new ObjectArrayList(); OpenIntObjectHashMap verticesFromLastTiers = new OpenIntObjectHashMap(); fillVerticesFromLastTier(hss, structures, verticesFromLastTiers); IVertex prevTierVertex = (IVertex) prevTier.get(prevVertexTierKey); IVertex nextTierVertex = (IVertex) nextTier.get(bottomVertex1.getTripletValue().getTierKey()); IVertex prevTierVertex = (IVertex) prevTier.get(prevVertexTierKey); IVertex prevTierVertex = (IVertex) prevTier.get(prevVertexTierKey); IVertex nextTierVertex = (IVertex) nextTier.get(bottomVertex2.getTripletValue().getTierKey()); IVertex prevTierVertex = (IVertex) prevTier.get(prevVertexTierKey); prevVertexTierKey = ((IVertex) ((OpenIntObjectHashMap) basicGraph.getTiers().get(j)).values().get(0)).getTripletValue().getTierKey(); result.add(verticesFromLastTiers.get(0));
/** * 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[] { }); }
IVertex vertexToShift = (IVertex) prevTier.get(tierKeyOfTheVertexToShift); int sTierSize = ((OpenIntObjectHashMap) basicGraph.getTiers().get(s)).size(); ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h); intersections.clear(); IVertex sTierVertex = (IVertex) sTierVertices.values().get(sv); int intersectionsSize = ((ObjectArrayList) structuresForConcordantShift.hsIntersections.get(0)).size(); for (int h = 0; h < hss.size(); h++) ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h); ICompactTripletsStructure intersection = (ICompactTripletsStructure) intersections.get(v); structuresForConcordantShift.coincidentIntersections.add(intersection); ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h); ICompactTripletsStructure substructureEdge = (ICompactTripletsStructure) intersections.get(0); structuresForConcordantShift.substructureEdges.set(h, substructureEdge); ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h); ICompactTripletsStructure substructureEdge = (ICompactTripletsStructure) structuresForConcordantShift.substructureEdges.get(h); ICompactTripletsStructure intersection = (ICompactTripletsStructure) intersections.get(ks);
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity==0) capacity=1; // open addressing needs at least one FREE slot at any time. this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);
private static int countDirtyTiers(IHyperStructure basicGraph) { int count = 0; for (int i = basicGraph.getTiers().size() - 1; i >= 0; i--) { OpenIntObjectHashMap tierVertices = (OpenIntObjectHashMap) basicGraph.getTiers().get(i); IVertex tierVertex = (IVertex) tierVertices.get(tierVertices.keys().get(0)); if (tierVertex.isDirty()) { count++; } else { break; } } return count; }