Results 1 to 6 of 6

Thread: From Hash Table Remove an Unreferenced Element

  1. #1
    Join Date
    Nov 2009
    Posts
    862

    From Hash Table Remove an Unreferenced Element

    Hello, I am searching for the program from which I can able to get the solution for the Removing of an Unreferenced Element From hash table. I have tried it to search on internet, but I am not able to get the solution for it. So, if anyone from you knows what is the code to achieve it, then please help me to get it. If you know the reference books or some other source from which I can achieve it, then please help me to get it.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: From Hash Table Remove an Unreferenced Element

    Hello, if you want to remove an Unreferenced Element from the Hash table then you must need to make use of the code below and get your problem solved:
    Code:
    WeakReference weakReference = new WeakReference(VObj); 
    weakMap.put(OObjObject, weakReference); 
    obj = weakMap.OObjSet().objerator(); 
    while (obj.hasNext()) 
    {
    Object OObj = obj.next(); 
    weakReference = (WeakReference)weakMap.get(OObj); 
    if (weakReference == null) 
    {  
    } 
    else
     { 
    VObj = weakReference.get(); 
    } 
    }

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: From Hash Table Remove an Unreferenced Element

    Hello, I am not having more knowledge about the hash table, but I know the basic function provided by the Hash Table which are as below:
    • copy-hash-table
    • hash-table-count
    • hash-table-test
    • hash-table-size
    • hash-table-rehash-size
    • hash-table-rehash-threshold
    • hash-table-weakness

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: From Hash Table Remove an Unreferenced Element

    Hello, it is needed to first create a weak map. For creating weak map you need to make use of the following code:
    Code:
        Map WMap = new WeakHashMap();   
        WMap.put(objObject, valueObject);   
        Iterator iterator = WMap.objSet().iteratorerator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();
        }
    After creating the weakmap you can make use of the code below for removing Hash Table from an Unreferenced Element:
    Code:
        WeakReference weakreference = new WeakReference(valueObject);
        WMap.put(objObject, weakreference);
        iterator = WMap.objSet().iteratorerator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();   
            weakreference = (WeakReference)WMap.get(obj);
            if (weakreference == null) {
            } else {
                valueObject = weakreference.get();
            }
        }

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: From Hash Table Remove an Unreferenced Element

    Hello, I think you must need to make use of the books on java below for getting exact details about the Hash Table and Unreferenced Elements and removing of it:
    • Teach Yourself Java in 21 Days by Laura Lemay , Charles Perkins
    • Java Secrets by Elliotte Rusty Harold
    • Java Programming for Dummies by David Koosis, Donald J. Koosis
    • Java for Dummies by Aaron E. Walsh

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: From Hash Table Remove an Unreferenced Element

    Hey, I have got the code in java for Removing an Unreferenced Element from hash table.
    Code:
    import java.util.Iterator;
    import java.util.Map;
    import java.util.WeakHashMap;
    public class Main 
    {
      public static void main(String[] argv) throws Exception 
    {
        Map map = new WeakHashMap();
        Object object = "";
        Object Vobject = "";
        map.put(object, Vobject);
        Iterator iterator = map.keySet().iteratorerator();
        while (iterator.hasNext()) 
    {
          Object key = iterator.next();
        }
      }
    }

Similar Threads

  1. Find element in table
    By Lauren Ambrose in forum Software Development
    Replies: 6
    Last Post: 12-04-2010, 09:00 AM
  2. Add Or Remove An Element From Jsp
    By D_chapple in forum Software Development
    Replies: 5
    Last Post: 02-03-2010, 12:20 PM
  3. Creating a Hash Table in java
    By Sheenas in forum Software Development
    Replies: 5
    Last Post: 19-02-2010, 07:24 PM
  4. Powershell: declare hash table
    By Halina in forum Software Development
    Replies: 3
    Last Post: 02-06-2009, 12:15 AM
  5. Calculating a hash table automatically in SQL
    By Elijah in forum Software Development
    Replies: 4
    Last Post: 02-04-2009, 11:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,921,025.83867 seconds with 16 queries