Paolo Invernizzi <[email protected]> wrote:
Hi all,What's the best way to find an element into an array, drop it and shrink the array inplace, in D2?Thanks in advance, Paolo
T extract( T )( ref T[] haystack, const T element ) {
auto loc = indexOf( haystack, element );
T result = haystack[loc];
haystack = haystack[0..loc] ~ haystack[loc+1..$];
return result;
}
Not tested, but should work.
--
Simen
