Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Alternative Civs > Clash of Civilizations > Arrays VS linked-lists
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
04.Sep: `FC` 2.0.5 COMPLETED AND RELEASED
27.Jul: `FC` 2.0.4 COMPLETED AND RELEASED
16.Jul: `FC` 2.0.3 COMPLETED AND RELEASED

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
jacobo is offline jacobo
Chieftain

Jan 1970
time: 05:13
Post  Old Post 03-09-1999 02:53
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Arrays VS linked-lists Get a bigger avatar today!

Most of the code i have seen uses arrays rather then linked lists is there a speed or other issue behind this? The main reason I ask is I am planning to make a storage for all the treaty classes(see Diplomacy thread) and am wondering what method to use.

Mark_Everson is offline Mark_Everson
Clash of Civilizations Project Lead
Canton, MI
Jan 1970
time: 00:13
Question  Old Post 03-09-1999 03:49 Visit Mark_Everson's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Put an end to popups!

I haven't done any detailed tradeoff calculations... However, arrays mean that a map square can know what its index in a provinces' squares array is, making removing it from that array Much quicker that finding it in a linked list that could have around 1000 entries late in the game. (Most of the other arrays shouldn't grow that big.) However, on the downside I need to check for array size, and sometime resize the arrays. What do the experienced programmers think about this?

mca is offline mca
Chieftain
Odense, Denmark
Jan 1970
time: 06:13
Post  Old Post 03-09-1999 22:59
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton buy from Amazon

jacobo: I don't know what your experience level is, so I'll just give the lecture

It all depends on what operations you are going to use on the storage:

If the number of elements in the storage never changes, use an array. Indexing (element=storage[i] or storage[i]=element) is cheapest with arrays.

If the number of elements change over time, you may need something else.

Linked lists are cheap to iterate through, and removing/inserting elements is usually cheap, but indexing is really expensive.

Vectors (resizable arrays) feature cheap indexing and removing and inserting elements at the end of the vector is cheap, but removing/inserting elements in the middle of the vector is really expensive.

Hashtables feature somewhat cheap indexing, insert/remove, and iteration, but the elements are unordered. (They are my favorite when I want high flexibility and not high performance, and when I need to index by Strings and not ints).

The above is not the whole truth, but I think it comes close enough.

Also, you might want to take a look at the Java 2 Collection API in java.util.

Martin

JimC is offline JimC
Chieftain
Birmingham, England
May 1999
time: 05:13
Post  Old Post 03-09-1999 23:02 Visit JimC's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Browse Apolyton AD-FREE

Quick note:

Speed issue (may be important, may not be)....

Vector class is synchronized, ArrayList is identical but unsynchronized.

ArrayList is usually a lot faster, if you aren't using threads.

Jim

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:13.
Apolyton Time is 00:13.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0331 seconds (87.23% PHP - 12.77% MySQL) with 30 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net