Example #1
0
 /// <summary>
 /// Deletes the given tuple from the tupleStorage
 /// </summary>
 /// <param name="tuple"></param>
 /// <returns>true if the tuple was found</returns>
 public Boolean Take2(ITuple tuple)
 {
     for (int i = 0; i < TS.Count; i++)
     {
         lock (TS)
             if (tuple.Matches(TS[i]))
             {
                 Console.WriteLine("% Take2 (Removing): " + tuple);
                 TS.RemoveAt(i);
                 return(true);
             }
     }
     return(false);
 }
Example #2
0
        /// <summary>
        /// Finds a tuple that matches the one given
        /// </summary>
        /// <param name="tuple"></param>
        /// <returns> tuple that matches the argument</returns>
        public ITuple Read(ITuple tuple)
        {
            foreach (ITuple tup in TS)
            {
                lock (TS)
                    if (tuple.Matches(tup))
                    {
                        Console.WriteLine("% Read: " + tuple);
                        return(tup);
                    }
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// Finds list of tuples matching the given tuple
        /// </summary>
        /// <param name="tuple"> tuple to be matched to </param>
        /// <returns> list of matches found</returns>
        public List <ITuple> Take1(ITuple tuple)
        {
            List <ITuple> list = new List <ITuple>();

            for (int i = 0; i < TS.Count; i++)
            {
                if (tuple.Matches(TS[i]))
                {
                    list.Add(TS[i]);
                }
            }

            Console.WriteLine("% Take1 (matches): " + list.Count + "Tuple like " + tuple);
            return(list);
        }