void forceRemoveDelegate(System.Object aDelegate)
 {
     // XXX: remove it from both handlers ???
     {
         var enumerator = targetedHandlers.GetEnumerator();
         while (enumerator.MoveNext())
         {
             CCTouchHandler handler = enumerator.Current;
             if (handler.delegate_ == aDelegate)
             {
                 targetedHandlers.Remove(handler);
                 break;
             }
         }
     }
     {
         var enumerator = standardHandlers.GetEnumerator();
         while (enumerator.MoveNext())
         {
             CCTouchHandler handler = enumerator.Current;
             if (handler.delegate_ == aDelegate)
             {
                 standardHandlers.Remove(handler);
                 break;
             }
         }
     }
 }
        /** Changes the priority of a previously added delegate. The lower the number,
         * the higher the priority */
        public void setPriority(int priority, System.Object aDelegate)
        {
            NSUtils.Assert(aDelegate != null, "Got nil touch delegate!");

            CCTouchHandler handler = null;

            handler = findHandler(aDelegate);

            NSUtils.Assert(handler != null, "Delegate not found!");

            handler.priority = priority;

            rearrangeHandlers(targetedHandlers);
            rearrangeHandlers(standardHandlers);
        }
 int sortByPriority(CCTouchHandler first, CCTouchHandler second)
 {
     if (first.priority < second.priority)
     {
         return(-1);
     }
     else if (first.priority > second.priority)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
        void forceAddHandler(CCTouchHandler handler, List <CCTouchHandler> array)
        {
            int i = 0;

            var enumerator = array.GetEnumerator();

            while (enumerator.MoveNext())
            {
                CCTouchHandler h = enumerator.Current;
                if (h.priority < handler.priority)
                {
                    i++;
                }

                NSUtils.Assert(h.delegate_ != handler.delegate_, "Delegate already added to touch dispatcher.");
            }
            array.Insert(i, handler);
        }
        CCTouchHandler findHandler(System.Object aDelegate)
        {
            {
                var enumerator = targetedHandlers.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var handler = enumerator.Current;
                    if (handler.delegate_ == aDelegate)
                    {
                        return(handler);
                    }
                }
            }
            {
                var enumerator = standardHandlers.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var handler = enumerator.Current;
                    if (handler.delegate_ == aDelegate)
                    {
                        return(handler);
                    }
                }
            }

            if (toAdd)
            {
                var enumerator = handlersToAdd.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    CCTouchHandler handler = (CCTouchHandler)enumerator.Current;
                    if (handler.delegate_ == aDelegate)
                    {
                        return(handler);
                    }
                }
            }

            return(null);
        }
		int sortByPriority(CCTouchHandler first, CCTouchHandler second)
		{
			if (first.priority < second.priority)
				return -1;
			else if (first.priority > second.priority)
				return 1;
			else
				return 0;
		}
		void forceAddHandler(CCTouchHandler handler,List<CCTouchHandler> array)
		{
			int i = 0;
			
			var enumerator = array.GetEnumerator();
			while (enumerator.MoveNext()) {
				CCTouchHandler h = enumerator.Current;
				if( h.priority < handler.priority )
					i++;
				
				NSUtils.Assert( h.delegate_ != handler.delegate_, "Delegate already added to touch dispatcher.");
			}
			array.Insert (i, handler);
		}