arraylist

C# Permutation of an array of arraylists?

I have an ArrayList[] myList and I am trying to create a list of all the permutations of the values in the arrays. EXAMPLE: (all values are strings) myList[0] = { "1", "5", "3", "9" }; myList[1] = { "2", "3" }; myList[2] = { "93" }; The count of myList can be varied so its length is not known beforehand. I would like to be able to ...

c# When should I use List and when should I use arraylist?

As the title says when should I use List and when should I use ArrayList? Thanks ...

Groovy: How do I sort an ArrayList of String:s in length-of-string order?

How do I sort an ArrayList of String:s in length-of-string order in Groovy? Code: def words = ['groovy', 'is', 'cool'] // your code goes here: // code that sorts words in ascending length-of-word order assert words == ['is', 'cool', 'groovy'] There are certainly more than one way to do it - so I'll grant the answer to the person who ...

Java method: Finding object in array list given a known attribute value

I have a couple of questions actually. I have a class Dog with the following instance fields: private int id; private int id_mother; private int id_father; private String name=""; private String owner=""; private String bDate=""; I also have a class Archive which can instantiate Dog and put Dog objects into an ArrayList. I am trying...

Should I use a Listener or Observer?

Hi, I have a dropdown box in my GUI which shows the contents of an ArrayList in another class. New objects can be added to the ArrayList elsewhere in the GUI, so I need to know when it is updated, so I can refresh the dropdown menu. From what I can gather, my two options are to extend the ArrayList class to allow me to add my own change...

ArrayList in C#

Can we pass ArrayLists as arguments to methods in C#? ...

Unable to find assembly

I'm Serializing an ArrayList to a binary file in order to send it across TCP/IP. The serialized file is created by the server and I hope to be able to deserialize it with the client that I'm writing at the moment. However, when the client attempts to deserialize it throws a SerializationException because it can't find the assembly (pres...

When a form loads read txt file into array

I am working on a C# application where when a form loads, I want it to read in the contents of a txt file and store it to an array. Next, when a click a button on the form, I want the button click event to access the array. How do I pass the array to the button click event? My code below has an error "statusArray does not exist in cur...

How to display all elements in an arraylist?

Say I have a car class with attributes make and registration, and i create an ArrayList to store them. How do I display all the elements in the ArrayList? I have this code right now: public Car getAll() { for(int i = 0; i < cars.size(); i++) //cars name of arraylist { Car car = cars.get(i); { retu...

Adding an ArrayList into a class - what does it do?

Hi Following on from this Q of mine: http://stackoverflow.com/questions/754184/whats-the-best-way-to-make-this-java-program I was recommended to store a list in Lecturer class and Course class. So I did, and it looks something like this: public class Lecturer { private String id; private String name; List<Course> cours...

In .Net, how do you convert an ArrayList to a strongly typed generic list without using a foreach?

See the code sample below. I need the ArrayList to be a generic List. ArrayList arrayList = GetArrayListOfInts(); List<int> intList = new List<int>(); //Can this be foreach be condensed into one line? foreach (int number in arrayList) { intList.Add(number); } return intList; ...

Java: Check whether an array is a subset of another

How can I easily check to see if one ArrayList object is contained as a subset of another? ...

Usefulness of ArrayList<E>.clear()?

I was looking through the Java documentation, and I came across the clear() method of ArrayLists. What's the use of this, as opposed to simply reassigning a new ArrayList object to the variable? ...

Modify contents in foreach

I tend to use ArrayLists of structures. It is then very easy to cycle through the list with a foreach. The problem I have is I cant use a foreach to modify the structures contents and have to use a for and messy typecasts. ((dataStructure)files[x]).name = here; Is there a tidier way to do it? ...

adding items to an arraylist when a button in gridview is clicked.

I need to add the itemid from the list of rows when i click 'add to cart' button in the gridview, i was able to pass this itemid to a arraylist. but the problem is that everytime i click the button the previous itemid is overwritten with the new item instead i want the arraylist to expand. public partial class Drama_k : System.Web.UI.Pa...

C++: How come random deletion from a std::vector is faster than a std::list?

How come that random deletion from a std::vector is faster than a std::list? What I'm doing to speed it up is swapping the random element with the last and then deleting the last. I would have thought that the list would be faster since random deletion is what it was built for. for(int i = 500; i < 600; i++){ swap(vector1[i], vector...

Sort ArrayList

Hi Experts, Here is a simple sorting program of an ArrayList: ArrayList<String> list = new ArrayList<String>(); list.add("1_Update"); list.add("11_Add"); list.add("12_Delete"); list.add("2_Create"); Collections.sort(list); for (String str : list) { System.out.println(str.toString()); } I was expecting the output of this program a...

How can I calculate the difference between two ArrayLists?

Hi, I have two ArrayLists .(IN JAVA Programming Language) ArrayList A contains ['2009-05-18','2009-05-19','2009-05-21'] ArrayList B Contains ['2009-05-18','2009-05-18','2009-05-19','2009-05-19','2009-05-20','2009-05-21','2009-05-21','2009-05-22'] I have to compare ArrayLst A and ArrayLst B . The result ArrayList should contain the ...

ArrayList of Integers to one int?

what would be the easiest way to convert an ArrayList of Integers to one int, with the 1st Integer in the list being the 1st number in the int, etc. in Java? For example an ArrayList of Integers: 1 4 6 7 8 3 8 becomes the int value 1467838 ...

What's wrong with Collections.sort?

I have these strings in an ArrayList of String in no particular order but when I invoke Collections.sort(listReference), the sorted result is incorrect, why do 10 and 11 (the last 2 characters) come before 07, 08, 09? 12880 20090506054200001 12880 20090506054200002 12880 20090513070200003 12880 20090513070200004 12880 2009052020260...