🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: aus.computers.java
12 messages
12 total messages Started by someguy Thu, 18 May 2000 00:00
dynamic arrays
#676
Author: someguy
Date: Thu, 18 May 2000 00:00
11 lines
1486 bytes
i am having some difficulties with using undefined array lengths can anyone
help?

The problem is when u declare an array u can only setits size once, however
i need to make the array grow larger at certain times.  I have thought of
various ways of doing this in methods but itbecame difficult handling the
variables due to scope issue.  So i gueess is there such a thing in java as
a linked list where at any point i can add or insert an element into the
list dynamically? or do you have any other suggestions?

help is appreciated.
Re: dynamic arrays
#677
Author: Sup
Date: Thu, 18 May 2000 00:00
20 lines
1484 bytes
A vector object is a dynamic array .... you can find it in java.util.Vector

someguy <someguy@somewhere.com> wrote in message
news:958656104.72811@brs.ihug.com.au...
> i am having some difficulties with using undefined array lengths can
anyone
> help?
>
> The problem is when u declare an array u can only setits size once,
however
> i need to make the array grow larger at certain times.  I have thought of
> various ways of doing this in methods but itbecame difficult handling the
> variables due to scope issue.  So i gueess is there such a thing in java
as
> a linked list where at any point i can add or insert an element into the
> list dynamically? or do you have any other suggestions?
>
> help is appreciated.
>
>
Re: dynamic arrays
#678
Author: Joern W. Janneck
Date: Thu, 18 May 2000 00:00
17 lines
1335 bytes
any java.util.List implementation is. you might want to use
java.util.ArrayList (similar to Vector but not synchronized and thus faster)
or java.util.LinkedList.

-- j

"Sup" <sup@ihug.com.au> wrote in message
news:8g0r6r$hos$1@bugstomper.ihug.com.au...
> A vector object is a dynamic array .... you can find it in
java.util.Vector
>
> someguy <someguy@somewhere.com> wrote in message
> news:958656104.72811@brs.ihug.com.au...
> > i am having some difficulties with using undefined array lengths can
> anyone
> > help?
[snip]
Re: dynamic arrays
#679
Author: someguy
Date: Thu, 18 May 2000 00:00
29 lines
1931 bytes
the vector is reffered to as a "fail fast" variable type, should this be of
concern to me?
"Sup" <sup@ihug.com.au> wrote in message
news:8g0r6r$hos$1@bugstomper.ihug.com.au...
> A vector object is a dynamic array .... you can find it in
java.util.Vector
>
> someguy <someguy@somewhere.com> wrote in message
> news:958656104.72811@brs.ihug.com.au...
> > i am having some difficulties with using undefined array lengths can
> anyone
> > help?
> >
> > The problem is when u declare an array u can only setits size once,
> however
> > i need to make the array grow larger at certain times.  I have thought
of
> > various ways of doing this in methods but itbecame difficult handling
the
> > variables due to scope issue.  So i gueess is there such a thing in java
> as
> > a linked list where at any point i can add or insert an element into the
> > list dynamically? or do you have any other suggestions?
> >
> > help is appreciated.
> >
> >
>
>
Re: dynamic arrays
#680
Author: Markus Laun
Date: Thu, 18 May 2000 00:00
8 lines
1059 bytes

someguy wrote:
> 
> what disadvantages do i have with the java.utils.ArrayList
> java.util.LinkedList not being synchronized?

don't access them from multiple threads, and you'll be fine!
Re: dynamic arrays
#681
Author: Phil Earnhardt
Date: Thu, 18 May 2000 00:00
31 lines
2167 bytes
On Fri, 19 May 2000 00:06:05 +1000, "someguy" <someguy@somewhere.com> wrote:

>what disadvantages do i have with the java.utils.ArrayList
>java.util.LinkedList not being synchronized?

Quoting from _The Java Class Libraries Second Edition, Volume 1
Supplement for the Java 2 Platform_ :

"java.util.ArrayList

Synchronization

The list allows more than one thread to read from it. However, if a thread
wants to modify the list, there should not be any thread reading from it at
the same time. If reads and modifications need to be able to occur
concurrently, you can create a synchronized version of the list by calling
Collections.synchronizedList() on the list. This creates a version of the
list in which all of the methods are synchronized. Note that although each
method might still need to synchronize a sequence of method calls. See the
Collections class description for more details."


Doug Lea, author of _Concurrent Programming in Java_, did much of the
initial work on the collection framework. Providing selectable concurrency
protection is one of the key features in its design.

As an aside, I really like the writeups and examples in the Java Class
Libraries books. If you have this kind of question with any frequency, they
are worthwhile books to have around.

--phil
Re: dynamic arrays
#682
Author: fungus
Date: Thu, 18 May 2000 00:00
25 lines
1656 bytes

someguy wrote:
> 
> i am having some difficulties with using undefined array lengths can anyone
> help?
> 
> The problem is when u declare an array u can only setits size once, however
> i need to make the array grow larger at certain times.  I have thought of
> various ways of doing this in methods but itbecame difficult handling the
> variables due to scope issue.  So i gueess is there such a thing in java as
> a linked list where at any point i can add or insert an element into the
> list dynamically? or do you have any other suggestions?
> 

Yes, look for java.util.Vector

If you're using Java2, you've also got other options
to choose from, including java.util.LinkedList.


-- 
<\___/>
/ O O \
\_____/  FTB.
Re: dynamic arrays
#683
Author: Phil Earnhardt
Date: Thu, 18 May 2000 00:00
27 lines
1936 bytes
On 18 May 2000 12:29:03 -0600, pae@dimensional.com (Phil Earnhardt)
wrote:

>On Fri, 19 May 2000 00:06:05 +1000, "someguy" <someguy@somewhere.com> wrote:
>
>>what disadvantages do i have with the java.utils.ArrayList
>>java.util.LinkedList not being synchronized?
>
>Quoting from _The Java Class Libraries Second Edition, Volume 1
>Supplement for the Java 2 Platform_ :
>
>"java.util.ArrayList
>
>Synchronization
>
>The list allows more than one thread to read from it. However, if a thread
>wants to modify the list, there should not be any thread reading from it at
>the same time. If reads and modifications need to be able to occur
>concurrently, you can create a synchronized version of the list by calling
>Collections.synchronizedList() on the list. This creates a version of the
>list in which all of the methods are synchronized. Note that although each
>method might still need to synchronize a sequence of method calls. See the
>Collections class description for more details."

I failed to mention: java.util.LinkedList works exactly the same way.

--phil
Re: dynamic arrays
#684
Author: someguy
Date: Fri, 19 May 2000 00:00
24 lines
1773 bytes
what disadvantages do i have with the java.utils.ArrayList
java.util.LinkedList not being synchronized?
"Joern W. Janneck" <janneck@NOSPAM.tik.ee.ethz.ch> wrote in message
news:3923f57c@pfaff.ethz.ch...
> any java.util.List implementation is. you might want to use
> java.util.ArrayList (similar to Vector but not synchronized and thus
faster)
> or java.util.LinkedList.
>
> -- j
>
> "Sup" <sup@ihug.com.au> wrote in message
> news:8g0r6r$hos$1@bugstomper.ihug.com.au...
> > A vector object is a dynamic array .... you can find it in
> java.util.Vector
> >
> > someguy <someguy@somewhere.com> wrote in message
> > news:958656104.72811@brs.ihug.com.au...
> > > i am having some difficulties with using undefined array lengths can
> > anyone
> > > help?
> [snip]
>
>
Re: dynamic arrays
#688
Author: Paul Murray
Date: Sat, 20 May 2000 00:00
24 lines
1759 bytes
in JDK1.2 - use a java.util.arrayList . in Jdk1.1, use a java.util.Vector

--
--------------------------------------------------------------
http://www.users.bigpond.com/pmurray
ICQ: 26066755
"someguy" <someguy@somewhere.com> wrote in message
news:958656104.72811@brs.ihug.com.au...
> i am having some difficulties with using undefined array lengths can
anyone
> help?
>
> The problem is when u declare an array u can only setits size once,
however
> i need to make the array grow larger at certain times.  I have thought of
> various ways of doing this in methods but itbecame difficult handling the
> variables due to scope issue.  So i gueess is there such a thing in java
as
> a linked list where at any point i can add or insert an element into the
> list dynamically? or do you have any other suggestions?
>
> help is appreciated.
>
>
Re: dynamic arrays
#689
Author: Paul Murray
Date: Sat, 20 May 2000 00:00
12 lines
1286 bytes
"someguy" <someguy@somewhere.com> wrote in message
news:958658471.384746@brs.ihug.com.au...

> the vector is reffered to as a "fail fast" variable type, should this be
of
> concern to me?

no.

-------------------------------------------------------------
http://www.users.bigpond.com/pmurray
ICQ: 26066755
Re: dynamic arrays
#690
Author: Joern W. Janneck
Date: Sat, 20 May 2000 00:00
12 lines
1203 bytes
"someguy" <someguy@somewhere.com> wrote in message
news:958658471.384746@brs.ihug.com.au...
> the vector is reffered to as a "fail fast" variable type, should this be
of
> concern to me?

it helps in locating bugs of the type 'you've got a live iterator on the
vector and someone changes its structure (without going through the
iterator).' can be helpful.

-- j
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads