All pastes #145025 Raw Edit

line

public text v1 · immutable
#145025 ·published 2006-08-22 19:59 UTC
rendered paste body

template has(T) {
	bool has(T[] array, T[] CmpArray) {
		return (where(array, CmpArray)!=-1);
	}
}

template where(T) {
	int where (T[] array, T[] CmpArray) {
		if (CmpArray.length>array.length) return -1;
		for (size_t i=0; i<array.length-CmpArray.length+1; ++i) {
			bool identical=true;
			for (size_t j=0; j<CmpArray.length; ++j) {
				if (array[i+j]!=CmpArray[j]) {
					identical=false; break;
				}
			}
			if (identical) return i;
		}
		return -1;
	}
}