I read data from a text file, so there may be
John
Mary
John
Leeds
and I need to get 3 elements in the ArrayList, cause there are only 3 unique values in the file.
I can use the hidden HashTable and add information to it, then simply copy its data into the List.
Are there other solutions?
...
I have to use a thousands of data read off from a file, and use the data hundreds of times repetitively in order to train and test my AI algorthm. Right now, I have two possible solutions. One is to keep reading off directly from the file everytime I need to use the thousands of data. The other one is to read off from the file and store...
Hi,
I have an arraylist of objects, each containing a unique date in the following format
YEAR-DAY-MONTH HOUR:MINUTE:SECOND (example: 2010-02-10 23:32:14)
I'm trying to compare each object in the array list (there are a few thousand) with a incrementing timer class I created to check if both times match. It seems like the easiest wa...
The problem
I have an array of java.awt.Rectangles. For those who are not familiar with this class, the important piece of information is that they provide an .intersects(Rectangle b) function.
I would like to write a function that takes this array of Rectangles, and breaks it up into groups of connected rectangles.
Lets say for examp...
ArrayList myList = new ArrayList();
ListView listView = (ListView) findViewById(R.id.list);
ArrayAdapter<MyClass> adapter = new ArrayAdapter<MyClass>(this, R.layout.row, to, myList.);
listView.setAdapter(adapter);
Class: MyClass
class MyClass {
public String reason;
public long long_val;
}
I want to show this in listView. I have...
Does anyone have any idea, why removeRange method in AbstractList (and also in ArrayList) is protected? It looks like a quite well-defined and useful operation, but still, to use it, we're forced to subclass the List implementation.
Is there some hidden rationale? Seems quite inexplicable to me.
...
ArrayList array = new ArrayList();
Iterator it1 = array.iterator();
while (it1.hasNext()){
Myclass temp = it1.myGetterMethod();
System.out.println (temp);
}
This is what I would like to implement, but Iterator only returns a generic Object. When I call Object.getClass(), the class is Myclass. Does this mean that the Iterator is ...
Hi, I'm having trouble parsing input from a file. The file is separated by lines, using ':' as a delimeter value. I'm having trouble getting the input into an ArrayList, and I think it's because I'm ineffectively using a variable within the while loop. If the variable newItin changes, it is still referencing the same object, or rather is...
what is the difference between arraylist and List<> in c#?
is it only that List<> have a type while ArrayList don't?
...
I'm creating a TableModel which will have a fixed number of columns, but the number of rows will be changing (mostly, increasing as function of time). Which would be better approach to store the data,
ArrayList[] columns = new ArrayList[numberOfColumns];
// Each array element is one column. Fill each of them with a new ArrayList.
...
pu...
Hi there
I'm busy preparing for the MCTS 70-536 exam, according to the exam book (Microsoft Press - .NET Framework - Application Development Foundation Self Paced Training Kit 2nd Edition), this code sample:
ArrayList al = new ArrayList();
al.AddRange(new string[] { "Hello", "world", "this", "is", "a", "test" });
Console.WriteLine(al.B...
Say I have an ArrayList of USBDevice Objects. Each USBDevice has ProductID and VendorID properties (among others). I want to create another ArrayList that is a subset of the first that contains only USBDevice that match a specific VID. What is the shortest way of doing this? I haven't tried this yet but can lambda expressions be used lik...
I can't figure out a discrepancy between the time it takes for the Contains method to find an element in an ArrayList and the time it takes for a small function that I wrote to do the same thing. The documentation states that Contains performs a linear search, so it's supposed to be in O(n) and not any other faster method. However, while...
Hi there,
I'm using Powershell 1.0 to remove an item from an Array. Here's my script:
param (
[string]$backupDir = $(throw "Please supply the directory to housekeep"),
[int]$maxAge = 30,
[switch]$NoRecurse,
[switch]$KeepDirectories
)
$days = $maxAge * -1
# do not delete directories with these values in the path
$...
When i populate an ArrayAdapter, at first the rows in the visible part of the screen will be blank except the first row, which will be an undesired result. Then when I scroll it down and then come back all the screen will be set correctly...please some one tell me why this behavior happens ?
Code :
homeListView = (ListView) fin...
Is it possible to do this in Java? Maybe I'm using the wrong syntax?
ArrayList<Integer> iAL = new ArrayList<Integer>();
iAL.addAll(Arrays.asList(new Integer[] {1, 2, 3, 4, 5 }));
for (int i = 0; i < iAL.size(); ++i) {
System.out.println(iAL[i]); //<-------- HERE IS THE PROBLEM
}
Also, is it possible to do something like
iAL.addA...
I have an ArrayList which contains fixed type of objects.
However everytime I need to extract an object a particular index, I need to typecast it to my user defined type from object type.
Is there a way in C# to declare ArrayList of fixed types just like Java and C++, or is there a work around to avoid the typecasting everytime?
Edit:...
What is the best/easiest way to sort a large list of words (10,000-20,000) by the number of times they occur in the list, in Java. I tried a basic implementation but I get an out of memory runtime error, so I need a more efficient way. What would you suggest?
ArrayList<String> occuringWords = new ArrayList<String>();
ArrayList<Integ...
Hi,
I'm trying to delete an int[] from an ArrayList.
Due to my code I only have the values so I'm creating the array and then call remove();
int[] pos = new int[]{0,1};
positionList.remove(pos);
positionList is the corrisponding ArrayList
This actually doesn't work. Is there another possibility than iterating through the list like
f...
Hi all,
I've been mulling this over & reading but can find an absolute authoritative answer.
I have several deep data structures made up of objects containing ArrayLists, Strings & primitive values. I can guarantee that the data in these structures will not change (no thread will ever make structural changes to lists, change references...