arraylist

What's Wrong with an ArrayList?

Recently I asked a question on SO that had mentioned the possible use of an c# ArrayList for a solution. A comment was made that using an arraylist is bad. I would like to more about this. I have never heard this statement before about arraylists. could sombody bring me up to speed on the possible performance problems with using arrayli...

why does this code output "0"?

package Algorithms; import cs1.Keyboard; import java.util.*; public class SieveofEratosthenes2 { public static void main (String[] args){ //input number and create an array with the length of (num-1) int num = Keyboard.readInt(); ArrayList prime = new ArrayList(num); //populate array with all number...

Adding multiple BigInteger values to an ArrayList

I want to add multiple BigInteger values to an ArrayList. All I have found is examples that repeatedly add single values, each expressed on their own line of code. I'm looking for something like ArrayList<BigInteger> array = {bigInt1, bigInt2, bigInt3}; and instead it's: ArrayList<BigInteger> array = new ArrayList<BigInteger>(); arra...

How to successfully access and loop an ArrayList by multiple threads?

I need help in ArrayList. I have an arraylist of strings. I am looping through this list and sending them to the output stream one after the other. While I am looping through the list and sending them, it is possible that another thread will be adding some elements to it. After an element is sent, it must be removed from the list as well...

Search using two keys in an arrayList

Hi all, I would like to implement a fast search on an ArrayList of objects. These objects consist of an int oldId, int newId and int inList, among with other things. Now, I tried implementing a binary search using the Collections.binarySearch on my list, but the problem is I need to search using the oldId and inList, to get the newId f...

Sorting ArrayList of Objects by Object attribute

Hi, I am having an Arraylist of Objects. Those object have an attribute or datatype - 'String'. I need to sort the Arraylist by that string. How to achieve this? ...

recursive + 900 elements + neighbor check = causes stackoverflow

Hi, I have a city simulation game and try to find a way to check the flow of our power system. The basics: The map for the city is based on tiles (30 by 30 tiles = 900 tiles). Now i start at a power plant and do a recursive neighbor check (top, left, right, bottom) to check if there is something that will transport the power. If there i...

Objective C equivalent to Java's ArrayList

Just wondering if there is an equivalent to Java's ArrayList in Objective-C? Or something that can be used to store objects/data that does not have a set size. Thanks. ...

C# objects in arrayLists. Please help!

Hello! I am working with arrayLists in C# and I am wondering how I can add objects to an arrayList and then retrieve the values from it? In short, how can I add, delete, edit and read from an Arraylist containing objects of classes? Thankful for all help! ...

problem deleting elements in arraylist

I'm doing a simple program using arraylist. But I've encountered an error. After deleting an element in the arraylist, using this code: delnum=scanz.nextLine(); intdelnum=Integer.parseInt(delnum); nem.remove(intdelnum); corz.remove(intdelnum); skul.remove(intdelnum); gen.remove(intdelnum); I'm having problems with adding another rec...

Arraylist to list<t>?

How can I convert/dump an arraylist into a list? I'm using arraylist because I'm using the ASP.NET profiles feature and it looked like a pain to store List in profiles. Note: The other option would be to wrap the List into an own class and do away with ArrayList. http://www.ipreferjim.com/site/2009/04/storing-generics-in-asp-net-profi...

Java: StringUtils.join on an ArrayList returns NoSuchMethodError Exception

Hello. I have an ArrayList that i would like to join with a delimiter of ',', i read in some answers here that StringUtils.join is a good option but the problem is that when i try to join an ArrayList i get the following error: java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.join(Ljava/util/Collection;C)Ljava/lang/Stri...

ArrayList of Hashtables in C#

I want to have an ArrayList where it contains HashTables. I create a Hashtable and added values. I then added it to the ArrayList. I then changed the values of the Hashtables and added it again the Array List. It does not save the first values and ending having duplicated values which were exactly the same as the last values! Any su...

How to store and read an array list of objects in java?

Hi, I am having difficulties w/ writing and reading an array of objects from a file. This is how my object looks like: package registar; import java.io.Serializable; public class Vozilo implements Serializable { private static final long serialVersionUID = -5302010108271068350L; private String registracija; private Stri...

ArrayList Problem in LINQ

Hi, i have problem LINQ query.In above,i got error system.object cant be converted to Sytem.String. What can be the problem? if i use string() instead of ArrayList, it doesn't raise error. But in String(), i should add items manually Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer, ByVal con...

What's missing from this strategy of choosing which C# collection to use?

Here's my strategy for choosing which C# collection type to use: if number of items in collection is fixed, then use an array, e.g.: string[] directions = new string[] { "north", "south", "east", "west" }; otherwise always use List<T> unless of course you need a more specialized collection, e.g. Stack<T>, Queue<T>, or Dictionary<TKey,...

java vector to arraylist

Is there any way to copy or convert a vector to arraylist in Java? ...

How can I extract ArrayList from HashMap and loop through it in Java?

I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String, ArrayList<String>>(); ... and I populate this by storing for every name (key), a list of names (value). So: ArrayList<String> saAccused = new ArrayList<String>(); // populate 'saAccused' ArrayList ... // done populating theAccused.put(sAc...

Compare two ArrayList Contents using c#

I have two arraylist. Namely ExistingProcess and CurrentProcess. The ExistingProcess arraylist contains the list of process that was running when this application started. The CurrentProcess arraylist is in a thread to fetch the process running in the system all the time. Each time the currentProcess arraylist gets the current process...

Convert a String (formatted just like an ArrayList<String>) to an actual ArrayList<String>

Hi, I am trying to convert a String into an ArrayList. For example, my Struts2 webapp returns this String named row in a format similar to this: [A, BB, CCC, DDDD, 1, 0, 1] (something along those lines) I need to convert them into an ArrayList so I can prepopulate some forms in another JSP page. I hardcoded a method to convert such St...