Package java.util

Examples of java.util.IdentityHashMap$Values


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


    public String toString() {
    return map.toString();
  }

  public static <K,V> Map<V,K> invert(Map<K,V> map) {
    Map<V,K> result = new IdentityHashMap( map.size() );
    for ( Entry<K, V> entry : map.entrySet() ) {
      result.put( entry.getValue(), entry.getKey() );
    }
    return result;
  }
View Full Code Here

                        }
                        case ID_CC_HASHTABLE: {
                            return replace(readMapData(unshared, -1, len, new Hashtable(len)));
                        }
                        case ID_CC_IDENTITY_HASH_MAP: {
                            return replace(readMapData(unshared, -1, len, new IdentityHashMap(len)));
                        }
                        case ID_CC_LINKED_HASH_MAP: {
                            return replace(readMapData(unshared, -1, len, new LinkedHashMap(len)));
                        }
                        case ID_CC_TREE_MAP: {
View Full Code Here

   public Object invoke(Invocation invocation) throws Throwable
   {
      try
      {
         ManagedEntityManagerFactory.nonTxStack.push(new IdentityHashMap());
         return invocation.invokeNext();
      }
      finally
      {
         Map map = ManagedEntityManagerFactory.nonTxStack.pop();
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();
        Map newListValueIndex = new IdentityHashMap();
       
        // Step 1 - Go through the old list.
        if (oldList != null) {
            ListIterator iterator = (ListIterator)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 = (ListIterator)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 = (ListIterator)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;
                                        }
                                    }
                                }
View Full Code Here

     */
    private Map getValueMap()
    {
        if (valueMap == null)
        {
            valueMap = new IdentityHashMap();
        }
        return valueMap;
    }
View Full Code Here

                           getCodebaseMap())
        );

        // set up new indirection maps for this encapsulation

        valueMap = new IdentityHashMap();
        repIdMap = new HashMap();
        codebaseMap = new HashMap();

        // the start of this encapsulation
View Full Code Here

  /**
   * Create an IdentitySet with default sizing.
   */
  public IdentitySet() {
    this.map = new IdentityHashMap();
  }
View Full Code Here

   * Create an IdentitySet with the given sizing.
   *
   * @param sizing The sizing of the set to create.
   */
  public IdentitySet(int sizing) {
    this.map = new IdentityHashMap( sizing );
  }
View Full Code Here

   *
   * @param event The create event to be handled.
   * @throws HibernateException
   */
  public void onPersist(PersistEvent event) throws HibernateException {
    onPersist( event, new IdentityHashMap(10) );
  }
View Full Code Here

TOP

Related Classes of java.util.IdentityHashMap$Values

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.