defining "in" What is the proper way in D2?

Vladimir Panteleev vladimir at thecybershadow.net
Sun Sep 11 13:25:17 PDT 2011


On Sun, 11 Sep 2011 23:02:37 +0300, Charles Hixson  
<charleshixsn at earthlink.net> wrote:

> I can't figure it out from  
> http://www.digitalmars.com/d/2.0/operatoroverloading.html#Binary

// I assume your data structure looks like this
class Node(Key, Data)
{
	Key k;
	Node!(Key, Data) left, right;
	int level;
	// ...

	void opBinary!("in")(Key k)
	{
		if	(level == 0)	return	false;
		if	(k < key)   	return	k in left;
		if	(key < k)   	return	k in right;
		return	true;
	}
}
-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d-learn mailing list