Re: Question About LinkedList
From: Edward H. Fabrega (spiritualfields_at_charter.net)
Date: 09/23/04
- Next message: Stefan Schulz: "Re: Dealing with inheritance anomalies in Java"
- Previous message: Rogue Chameleon: "Encryption & Decryption"
- In reply to: John C. Bollinger: "Re: Question About LinkedList"
- Next in thread: John C. Bollinger: "Re: Question About LinkedList"
- Reply: John C. Bollinger: "Re: Question About LinkedList"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Sep 2004 11:57:41 -0700
"John C. Bollinger" <jobollin@indiana.edu> wrote in message
news:ciusev$g9k$1@hood.uits.indiana.edu...
> You have not even come close to specifying all your requirements. I
> suspect that the term "database" has a very specific meaning to you, at
> least in this context, but it does not illuminate us very well. Enumerate
> (for yourself) all the functional requirements, and determine how well
> your proposed model will handle them. If you need help with such an
> evaluation then ask some more specific questions here.
>
> To get you going, here are some of the key characteristics of the two main
> List implementations:
>
> ArrayList
> ---------
> ()Indexed element access is fast (constant time).
> ()List additions (at the end) sometimes require copying the entire backing
> array (to a larger array), but usually not. Adding a large number of
> elements is O(log N), if I've worked it out right.
> ()List insertions (not at the end) require moving the elements at and
> after the insertion position, and sometimes requires moving all the
> elements (when a larger array is required).
> ()List deletions usually require moving some or all of the elements of the
> backing array to new positions (O(N)).
>
> LinkedList
> ----------
> ()Indexed element access is slow (O(N) for random indices) because the
> List must be traversed from one end to the desired element. The specific
> cases of access to the first and last elements are fast, however.
> ()Additions and deletions at beginning or end are O(1)
> ()_Indexed_ additions and deletions are O(N) for random indices, because
> of the time required to traverse the list to the appropriate location.
> ()List mutations never require copying the backing data structure.
> ()The List's ListIterator is your friend. Use it instead of indexes
> wherever possible.
Thanks for that information. It looks like an ArrayLists of ArrayLists is
better than a LinkedList of ArrayLists. What my goal is is to write a
database program, similar to the one I wrote a couple of years ago in C++
MFC:
http://members.aol.com/spiritualfields/index.htm
The screenshots will give you a good idea of the view. It looks like a
JTable will work for the UI. I'm not even close to coding yet, as I'm
familiarizing myself with the java language and the jdk api. The underlying
data model that I had used for MyAuctionHelper was a linked list of
StringArrays. The view was modeled after Access, but I didn't use a
component, I painted it myself and coupled it to the database, but I do not
want to go through that again. The only constraint that I can think of right
now is that the data structure must compatible with JTables, and unless I'm
wrong, an ArrayLists of ArrayLists works with the JTable(Object[][] ,
Object[]) constructor. This will be a standalone application, and not
necessarily a remake of my previouis program. Between now and when I
actually start coding I could get other ideas. What is absolutely essential
is that the database is completely encapsulated so I can resuse it. I could
be wrong, but it looks like the javax.swing api almost forces encapsulation
if I use JTables as the view. I'm not sure if I have any more questions
explicitly, I'm still learning the nuts and bolts of java. If you have any
ideas or insights on modeling databases (flat file) with java, I'll be
interested to hear them.
- Next message: Stefan Schulz: "Re: Dealing with inheritance anomalies in Java"
- Previous message: Rogue Chameleon: "Encryption & Decryption"
- In reply to: John C. Bollinger: "Re: Question About LinkedList"
- Next in thread: John C. Bollinger: "Re: Question About LinkedList"
- Reply: John C. Bollinger: "Re: Question About LinkedList"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|