[Mono-list] Array Class
Martin Baulig
martin@gnome.org
10 Mar 2002 02:47:36 +0100
"Dwivedi , Ajay Kumar" <AjayKumar.Dwivedi@dresdner-bank.com> writes:
> 2. Implementing the iterator for all dimensions should be very easy if we
> have "internal extern object GetValueImpl (int pos);" implemented. I suppose
> this would return an object based on position and not indices.
This function already exists as interncall. It takes a position and returns an
object.
> 3. All versions of BinarySearch except the most generic one should be spared
> of the array==null check.
The check is required since you can't call GetLowerBound() or GetLength() on
a null reference:
====
public static int BinarySearch (Array array, object value)
{
if (array == null)
throw new ArgumentNullException ();
return BinarySearch (array, array.GetLowerBound (0), array.GetLength (0),
value, null);
}
====
The only way to get rid of this (an similar checks) is to add a second
interncall for GetLowerBound and GetLength which allows being called
on a null reference - but I doubt that this makes any sense, a simple
null check should be about the same overhead in C# and C and the code
looks cleaner the way it is now.
> 4. Clear should be implemented as an InternalCall. The loop might be quite
> costly, whereas the same can be done using something like bzero in C (BTW I
> don't have even slightest idea about how we do internalcall implementations,
> so I might be wrong here)
Yes, I agree. This can be done in a similar way like FastCopy.
--
Martin Baulig
martin@gnome.org