Package java.util

Examples of java.util.IdentityHashMap$ValueIterator


  private IdentityHashMap lpDB;   //K: LogicalProcess  E: null
  private Executive exec;

  public CachingPopulationManager() {
    super();
    popMap = new IdentityHashMap();
    lpDB = new IdentityHashMap();
  }
View Full Code Here


   * @see org.mitre.sim.exec.flex.PopulationManager#createPopulation(java.lang.Class)
   */
  public Population createPopulation(Class c) {
    CachedPopulation cp = (CachedPopulation)popMap.get(c);
    if (cp == null) {
      IdentityHashMap contents = new IdentityHashMap();
      for (Iterator i = lpDB.keySet().iterator(); i.hasNext(); ) {
        LogicalProcess lp = (LogicalProcess)i.next();
        if (c.isInstance(lp)) contents.put(lp, null);
      }
      cp = new CachedPopulation(contents);
      popMap.put(c, cp);
    }
    return cp;
View Full Code Here

    this.baseClass = baseClass;
  }

  protected IdentityHashMap compute() {
    Set lpDB = myExec.getLogicalProcesses();
    IdentityHashMap partialDB = new IdentityHashMap();
    for (Iterator i = lpDB.iterator(); i.hasNext(); ) {
      Entity e = (Entity)i.next();
      if (baseClass.isInstance(e)) partialDB.put(e, null);
    }
    return partialDB;
  }
View Full Code Here

   * @return the new Map instance
   * @deprecated as of Spring 2.5, for usage on JDK 1.4 or higher
   */
  @Deprecated
  public static Map createIdentityMapIfPossible(int initialCapacity) {
    return new IdentityHashMap(initialCapacity);
  }
View Full Code Here

   * @param initialCapacity the initial capacity of the Map
   * @return the new Map instance
   * @deprecated as of Spring 2.5, for usage on JDK 1.4 or higher
   */
  public static Map createIdentityMapIfPossible(int initialCapacity) {
    return new IdentityHashMap(initialCapacity);
  }
View Full Code Here

    private static Map createLinkedHashMap(int initialCapacity) {
      return new LinkedHashMap(initialCapacity);
    }

    private static Map createIdentityHashMap(int initialCapacity) {
      return new IdentityHashMap(initialCapacity);
    }
View Full Code Here

  public void createWeight(Map context, Searcher searcher) throws IOException {
  }

  /** Returns a new non-threadsafe context map. */
  public static Map newContext() {
    return new IdentityHashMap();
  }
View Full Code Here

    }

    void setDetailExpansionEnabled (boolean yn)
    {
        if (yn != detailExpansionEnabled()) {
            _detailRowExpansions = (yn) ? new IdentityHashMap() : null;
        }
    }
View Full Code Here

            // Since _detailAttributesExpanded is an IdentityHashMap, on regroup,
            // we need to remap to the new group instances
            if (_detailAttributesExpanded.size() > 0) {
                Collection<PivotGroup> newGroups = _dataTable._displayGroup.groupingValueState().values();
                Set<PivotGroup> expanded = new HashSet(_detailAttributesExpanded.keySet());
                _detailAttributesExpanded = new IdentityHashMap();
                for (PivotGroup g : newGroups) {
                    if (expanded.contains(g)) _detailAttributesExpanded.put(g, true);
                }
            }
        }
View Full Code Here

     */
    public void compareCollectionsForChange(Object oldList, Object newList, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor) {   
        Vector orderedObjectsToAdd = new Vector();
        Hashtable indicesToRemove = new Hashtable();
        Hashtable oldListIndexValue = new Hashtable();
        IdentityHashMap oldListValueIndex = new IdentityHashMap();
        IdentityHashMap objectsToAdd = new IdentityHashMap();
        IdentityHashtable newListValueIndex = new IdentityHashtable();
       
        // Step 1 - Go through the old list.
        if (oldList != null) {
            ListIterator iterator = iteratorFor(oldList);
       
            while (iterator.hasNext()) {
                Integer index = new Integer(iterator.nextIndex());
                Object value = iterator.next();
                oldListValueIndex.put(value, index);
                oldListIndexValue.put(index, value);
                indicesToRemove.put(index, index);
            }
        }
           
        // Step 2 - Go though the new list.
        if (newList != null) {
            // Step i - Gather the list info.
            ListIterator iterator = iteratorFor(newList);
            while (iterator.hasNext()) {
                newListValueIndex.put(iterator.next(), new Integer(iterator.previousIndex()));
            }
       
            // Step ii - Go through the new list again.       
            int index = 0;
            int offset = 0;
            iterator = iteratorFor(newList);
            while (iterator.hasNext()) {
                index = iterator.nextIndex();
                Object currentObject = iterator.next();
           
                // If value is null then nothing can be done with it.
                if (currentObject != null) {
                    if (oldListValueIndex.containsKey(currentObject)) {
                        int oldIndex = ((Integer) oldListValueIndex.get(currentObject)).intValue();
                        oldListValueIndex.remove(currentObject);
                   
                        if (index == oldIndex) {
                            indicesToRemove.remove(new Integer(oldIndex));
                            offset = 0; // Reset the offset, assume we're back on track.
                        } else if (index == (oldIndex + offset)) {
                            // We're in the right spot according to the offset.
                            indicesToRemove.remove(new Integer(oldIndex));
                        } else {
                            // Time to be clever and figure out why we're not in the right spot!
                            int movedObjects = 0;
                            int deletedObjects = 0;
                            boolean moved = true;
                       
                            if (oldIndex < index) {
                                ++offset;   
                            } else {
                                for (int i = oldIndex - 1; i >= index; i--) {
                                    Object oldObject = oldListIndexValue.get(new Integer(i));
                                    if (newListValueIndex.containsKey(oldObject)) {
                                        ++movedObjects;
                                    } else {
                                        ++deletedObjects;
                                    }
                                }
                           
                                if (index == ((oldIndex + offset) - deletedObjects)) {
                                    // We fell into place because of deleted objects.
                                    offset = offset - deletedObjects;
                                    moved = false;
                                } else if (movedObjects > 1) {
                                    // Assume we moved down, bumping everyone by one.
                                    ++offset;
                                } else {
                                    // Assume we moved down unless the object that was
                                    // here before is directly beside us.
                                    Object oldObject = oldListIndexValue.get(new Integer(index));
                               
                                    if (newListValueIndex.containsKey(oldObject)) {
                                        if ((((Integer) newListValueIndex.get(oldObject)).intValue() - index) > 1) {
                                            moved = false; // Assume the old object moved up.
                                            --offset;
                                        }
                                    }
                                }
                            }
                       
                            if (moved) {
                                // Add ourselves to the ordered add list.
                                orderedObjectsToAdd.add(currentObject);
                            } else {
                                // Take us off the removed list.
                                indicesToRemove.remove(new Integer(oldIndex));   
                            }
                        }
                    } else {
                        ++offset;
                        objectsToAdd.put(currentObject, currentObject);
                        orderedObjectsToAdd.add(currentObject);
                    }
                } else {
                    // If we find nulls we need decrease our offset.
                    offset--;
View Full Code Here

TOP

Related Classes of java.util.IdentityHashMap$ValueIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.