[RESOLVED] [1.0/1.1] ArrayList<Class> vs ArrayList<String>
I was just curious if I should even bother with creating a new class to hold 2 parameters of information or just hold them in an array list.
Currently I am sorting information into any arraylist like the following.
VB Code:
ArrayList _route = new ArrayList();
_route.Add(1 + "|" + 2);
_route.Add(5 + "|" + 24);
_route.Add(123 + "|" + 12);
// etc...
Would it be "better" to use a class or structure and add it to the ArrayList, I only ask because it would reduce extra parsing when extracting the information but MOST importantly would it hinder the performance?
VB Code:
public class Path
{
private Int32 _clid, _oid;
public Path(Int32 CLID, Int32 OID)
{
this._clid = CLID;
this._oid = OID;
}
public Int32 CLID
{
get { return _clid; }
}
public Int32 OID
{
get { return _oid; }
}
}
// Add information to arraylist using the path class.
ArrayList _route = new ArrayList();
_route.Add(new Path(1, 2));
_route.Add(new Path(5, 24));
_route.Add(new Path(123,12));
// etc...
The Path class could be instantiated up to 100+ times.
Any ideas or thoughts would be great.
Re: [1.0/1.1] ArrayList<Class> vs ArrayList<String>
You should declare a structure rather than a class, but a specific type is definitely in order.
Re: [1.0/1.1] ArrayList<Class> vs ArrayList<String>
Re: [1.0/1.1] ArrayList<Class> vs ArrayList<String>
I would expect performance to be exactly the same, since you're using 1.1 and there are no generics.
With a generic List<Path> in 2.0 the performance would definitely be faster.
Re: [1.0/1.1] ArrayList<Class> vs ArrayList<String>
I did have some time today to run a time test and using a structure is faster than that just the string append so going to use a structure.
I wish I could use generics :P