Do you want add contains and remove item Function in array?

FrankLike via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 5 06:09:04 PST 2015


Now operate array is not very quick,such as contains 
function,remove item function
can't get from arry module.

template contains(T)
{
	bool contains(T[] Array,T Element)
	{
		foreach(T ArrayElement; Array)
		{
			if(Element==ArrayElement)
			{
				return true;
			}
		}
		return false;
	}
}

template remove(T)
{
	bool remove(T[] Array,T Element)
	{
		?????
		return true;
	}
}

or

remove!("a == ?")(arr)

How to get the easy and quickly way?

Thank you.



More information about the Digitalmars-d mailing list