Data structure with an insert after element method?

  • Thread starter Thread starter Theo Chakkapark
  • Start date Start date
T

Theo Chakkapark

I'm sort of new to .NET, and was wondering if there was any kind of
dynamic data structure that allowed one to add an element after a
specified element (and therefore update the array index)?

I was looking at ArrayList, but I didn't see any such methods for this.
 
Theo said:
I'm sort of new to .NET, and was wondering if there was any kind of
dynamic data structure that allowed one to add an element after a
specified element (and therefore update the array index)?

I was looking at ArrayList, but I didn't see any such methods for this.

Both ArrayList and (the preferable, IMHO) List<> generic class include
an Insert() method that allows just that.

For example:

void InsertAfter(ArrayList list, Object obj, int iobj)
{
list.Insert(iobj + 1, obj);
}

Where "iobj" is the array index of the object after which you want the
new object inserted.

Pete
 
Back
Top