Exemplo n.º 1
0
        /**
         * Purges the specified reference.
         *
         * @param ref  the reference to purge
         */
        protected virtual void purge(java.lang.refj.Reference <Object> refj)
        {
            // The hashCode of the reference is the hashCode of the
            // mapping key, even if the reference refers to the
            // mapping value...
            int       hash     = refj.GetHashCode();
            int       index    = hashIndex(hash, data.Length);
            HashEntry previous = null;
            HashEntry entry    = data[index];

            while (entry != null)
            {
                if (((ReferenceEntry)entry).purge(refj))
                {
                    if (previous == null)
                    {
                        data[index] = entry.nextJ;
                    }
                    else
                    {
                        previous.nextJ = entry.nextJ;
                    }
                    this.sizeJ--;
                    return;
                }
                previous = entry;
                entry    = entry.nextJ;
            }
        }
Exemplo n.º 2
0
 /**
  * Purges stale mappings from this map.
  * <p>
  * Note that this method is not synchronized!  Special
  * care must be taken if, for instance, you want stale
  * mappings to be removed on a periodic basis by some
  * background thread.
  */
 protected virtual void purge()
 {
     java.lang.refj.Reference <Object> refj = queue.poll();
     while (refj != null)
     {
         purge(refj);
         refj = queue.poll();
     }
 }
Exemplo n.º 3
0
            /**
             * Purges the specified reference
             * @param ref  the reference to purge
             * @return true or false
             */
            internal bool purge(java.lang.refj.Reference <Object> refJ)
            {
                bool r = (parent.keyType > HARD) && (key == refJ);

                r = r || ((parent.valueType > HARD) && (value == refJ));
                if (r)
                {
                    if (parent.keyType > HARD)
                    {
                        ((java.lang.refj.Reference <Object>)key).clear();
                    }
                    if (parent.valueType > HARD)
                    {
                        ((java.lang.refj.Reference <Object>)value).clear();
                    }
                    else if (parent.purgeValues)
                    {
                        value = null;
                    }
                }
                return(r);
            }