Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Visual J# / June 2004

Tip: Looking for answers? Try searching our database.

Help in JAVA datastructure definition

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
johnpremi - 11 Jun 2004 11:18 GMT
Hi there,
I am a newbie to Java programming and would like to get some feedback on how I can proceed with a problem I have at hand. I have to maintain the objects information in the memory for a SITE. SITE has side id, site name, and a site will be related to devices (one or more devices). Devices will have information such as is it alive what is the frequency of its alive signal coming to the server. These information have to be in-memory all the time so that at any point of time I would have to pick the device alive signal and process the neccesary tasks such as send an email to user whose device is not working. (email information for each device as well will be maintained in the memory). What kind of data structure can I use to acheive this scanerio. I was thinking of HASHTABLE but I am unable to get any samples that can explain the HASHTABLE usage. If anyone could help me in getting the right information it will be really helpful.
Thanking you in advance

regards
John
Lars-Inge T?nnessen - 14 Jun 2004 17:39 GMT
Here is a hash table example I wrote for you. Please remember hash tables perform best when they are approx 75 % full.

In Java (and J#), please use the .GetHashCode() method to return the hash key for the objects.

If you want to allocate more space in runtime, please use the rehash() method on the hash table.

Sorry I can't give more advice on the arcitecture, as I don't have the details.

public class hello
{
   public int number = 0;

   public hello( int numb )
   {
       this.number = numb;
    }

   int retnumb( )
   {
       return this.number;
   }
}

public class Class1
{
   public Class1()
   {
       System.out.println("Start");
       java.util.Hashtable hash = new java.util.Hashtable(100);

       hello one = new hello(1);
       hello two = new hello(2);

       // key object
       hash.put( new Integer( one.GetHashCode()), (Object)one );
       hash.put( new Integer( two.GetHashCode()), (Object)two );

       // key
       hello got = (hello)hash.get( new Integer( one.GetHashCode()) );
       System.out.println("Got :"+got.retnumb() );
       System.out.println("End");
   }

   /** @attribute System.STAThread() */
   public static void main(String[] args)
   {
       new Class1();
   }
}

Regards,
Lars-Inge T?nnessen
www.larsinge.com

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.