Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-02-2007, 10:31 AM
Member
 
Join Date: Jun 2007
Posts: 21
ai_2007 is on a distinguished road
Creating a stack with data
I have to create a class 'Dear' that has a stack that will allow addition of 'event' information into it. The event information will include event type and date of event. All the data has to be sorted automatically while it is being added into the stack.

Please help me with this because I am not sure of how to do this.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-02-2007, 11:02 AM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Quote:
All the data has to be sorted automatically while it is being added into the stack.
If the stack objects need to be sorted then it is not called as stack anymore and implementing a stack for that purpose is unnecessary. Just use an ArrayList or Vector and while inserting an element search for the correct position and call insert method.

If there are some performance issues, you might search for a better data structure since, in my way, insertion can be slow when lots of data exist in a vector.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-02-2007, 04:28 PM
Member
 
Join Date: Jun 2007
Posts: 21
ai_2007 is on a distinguished road
Better data structure
You mentioned implementing a better data structure for more data.
Could you please illustrate what you mean by better data structure with the algorithm given?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stack data structure in Java Java Tip java.lang 0 04-16-2008 11:34 PM
JVM terminated while creating a new Data-Source woeko Eclipse 0 01-03-2008 01:28 PM
Stack Trace Java Tip Java Tips 0 12-10-2007 06:29 PM
Help Creating A Graph From Inputted Data adlb1300 New To Java 6 10-28-2007 05:45 AM
Help with heap and stack coco Advanced Java 1 08-06-2007 03:21 PM


All times are GMT +3. The time now is 12:21 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org