Main Site Documentation

What happens with NETMF 4.1 Arraylist Sort and RemoveRange are not there?


#1

what happens with NETMF arraylist? Sort and RemoveRange are not there.
using System.Collections;

ArrayList list = new ArrayList();
list.Sort();
list.RemoveRange(8, 2);
list.RemoveRange(0, 2);


#2

Good question.

Also Encoding.ASCII is missing, and Encoding.UTF8 is missing GetString() method. All this I’ve found in the first 30 minutes of playing with it… what are we missing?


#3

Moving from a 3ghz pc to a 72mhz chip will force you to lose some functionality. There still thousands of methods that should get you to what you need


#4

how about an example of array list sort :-)?


#5

Gotcha Gus. I thought it would be mostly compatible, but lighter weight and missing many of the features. Looks like many things are missing. Probably, as you said, a necessary evil for the size of devices supported.


#6

I think when ‘things are missing’ in NETMF is provides a big flag as to why you are wanting to use that thing that is missing. It seems as if most of what is not in NETMF has to do with memory and processing speed constraints of a small device. So, in this case having a sort may have allowed the original algorithm to work, but perhaps not been performant.

This situation provides a design challenge. How else can you accomplish the same thing without a sort?


#7
	public override void Sort( ArrayList items, int lo0, int hi0, IComparer comparer )
	{
		int i;
		int j;
		//int v;
		object tmpItem;

		for (i=lo0+1;i<=hi0;i++)
		{
			tmpItem = items[i];
			j=i;

			while ( (j>lo0) && ( comparer.Compare( items[j-1], tmpItem ) > 0  ) )
			{
				items[j] = items[j-1];
				j--;
			}

			items[j] = tmpItem;
		}
	}

Quick little insertion sort routine for you. IComparer is easy to figure out.