Esempio n. 1
0
        public virtual void addNewPartialMatch(IHashIndex index, IFact fact)
        {
            IGenericMap <object, object> matches = CollectionFactory.newMap();

            matches.Put(fact, fact);
            memory.Put(index, matches);
        }
Esempio n. 2
0
 public virtual int addNewPartialMatch(IHashIndex index, IFact fact)
 {
     IGenericMap<object, object> matches = CollectionFactory.newMap();
     matches.Put(fact, fact);
     memory.Put(index, matches);
     return 1;
 }
Esempio n. 3
0
        /// <summary> Remove a partial match from the memory
        /// </summary>
        public virtual int removePartialMatch(IHashIndex index, IFact fact)
        {
            IGenericMap <Object, Object> list = (IGenericMap <Object, Object>)memory[index];

            list.Remove(fact);
            if (list.Count == 0)
            {
                memory.Remove(index);
            }
            counter--;
            return(list.Count);
        }
Esempio n. 4
0
        public virtual int count(IHashIndex index)
        {
            IGenericMap <Object, Object> list = (IGenericMap <Object, Object>)memory[index];

            if (list != null)
            {
                return(list.Count);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 5
0
        public virtual bool isPartialMatch(IHashIndex index, IFact fact)
        {
            IGenericMap <Object, Object> list = (IGenericMap <Object, Object>)memory[index];

            if (list != null)
            {
                return(list.ContainsKey(fact));
            }
            else
            {
                return(false);
            }
        }
        /// <summary> Return an GetEnumerator of the values
        /// </summary>
        public virtual IEnumerator iterator(IHashIndex index)
        {
            IGenericMap <Object, Object> list = (IGenericMap <Object, Object>)memory.Get(index);

            if (list != null)
            {
                return(list.Values.GetEnumerator());
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        /// <summary> addPartialMatch stores the fact with the factId as the
        /// key.
        /// </summary>
        public virtual void addPartialMatch(IHashIndex index, IFact fact)
        {
            IGenericMap <Object, Object> matches = (IGenericMap <Object, Object>)memory[index];

            if (matches == null)
            {
                addNewPartialMatch(index, fact);
            }
            else
            {
                matches.Put(fact, fact);
            }
            counter++;
        }
Esempio n. 8
0
 /// <summary> addPartialMatch stores the fact with the factId as the
 /// key.
 /// </summary>
 public virtual int addPartialMatch(IHashIndex index, IFact fact)
 {
     IGenericMap<Object, Object> matches = (IGenericMap<Object, Object>) memory.Get(index);
     int count = 0;
     if (matches == null)
     {
         count = addNewPartialMatch(index, fact);
     }
     else
     {
         matches.Put(fact, fact);
         count = matches.Count;
     }
     counter++;
     return count;
 }
        /// <summary> addPartialMatch stores the fact with the factId as the
        /// key.
        /// </summary>
        public virtual int addPartialMatch(IHashIndex index, IFact fact)
        {
            IGenericMap <Object, Object> matches = (IGenericMap <Object, Object>)memory.Get(index);
            int count = 0;

            if (matches == null)
            {
                count = addNewPartialMatch(index, fact);
            }
            else
            {
                matches.Put(fact, fact);
                count = matches.Count;
            }
            counter++;
            return(count);
        }
Esempio n. 10
0
        /// <summary> Return an GetEnumerator of the values
        /// </summary>
        public virtual IEnumerator iterator(IHashIndex index)
        {
            IGenericMap <Object, Object> list = (IGenericMap <Object, Object>)memory[index];

            if (list != null)
            {
                // we have to create a new Creshendo.rete.util.List<Object> with the values
                // so the GetEnumerator will work correctly. if we didn't
                // do this, we might Get a NullPointerException or a
                // possibly a concurrent modification exception, since
                // the node could be still iterating over the facts
                // as stale facts are removed.
                System.Collections.Generic.List <Object> rlist = new System.Collections.Generic.List <Object>(list.Values);
                return(rlist.GetEnumerator());
            }
            else
            {
                return(null);
            }
        }
Esempio n. 11
0
 /// <summary> Remove a partial match from the memory
 /// </summary>
 public virtual int removePartialMatch(IHashIndex index, IFact fact)
 {
     IGenericMap<Object, Object> list = (IGenericMap<Object, Object>) memory.Get(index);
     if (list != null)
     {
         list.Remove(fact);
         if (list.Count == 0)
         {
             memory.Remove(index);
         }
         counter--;
         return list.Count;
     }
     else
     {
         return 0;
     }
 }
Esempio n. 12
0
 /// <summary> Return an GetEnumerator of the values
 /// </summary>
 public virtual IEnumerator iterator(IHashIndex index)
 {
     IGenericMap<Object, Object> list = (IGenericMap<Object, Object>) memory.Get(index);
     if (list != null)
     {
         return list.Values.GetEnumerator();
     }
     else
     {
         return null;
     }
 }
Esempio n. 13
0
 public virtual bool isPartialMatch(IHashIndex index, IFact fact)
 {
     IGenericMap<Object, Object> list = (IGenericMap<Object, Object>) memory.Get(index);
     if (list != null)
     {
         return list.ContainsKey(fact);
     }
     else
     {
         return false;
     }
 }
Esempio n. 14
0
 public virtual int count(IHashIndex index)
 {
     IGenericMap<Object, Object> list = (IGenericMap<Object, Object>) memory.Get(index);
     if (list != null)
     {
         return list.Count;
     }
     else
     {
         return 0;
     }
 }