/**
         * Add a mapping
         * @param key the key
         * @param state the state
         */
        public void add(SafraTree key, DA_State state)
        {
            AbstractedKeyType akey = new AbstractedKeyType(key);
            ValueList         list = new ValueList();

            list._key   = key;
            list._state = state;
            list._next  = null;

            //typename map_type::value_type value (akey, list);

            //std::pair<typename  map_type:: iterator,bool > result = _map.insert(value);



            if (_map.ContainsKey(akey))
            {
                // there is already an element with this structure
                // -> insert list into current list

                ValueList head = _map[akey];
                list._next = head._next;
                head._next = list;

                _map[akey] = head;
            }
            else
            {
                _map.Add(akey, list);
            }

            _count++;
        }
        /**
         * Search for a mapping, fuzzily
         * @param result the query
         * @return the corresponding state or NULL otherwise
         */
        public DA_State find(SafraTreeTemplate result)
        {
            //map_type::const_iterator it;

            AbstractedKeyType search_key = new AbstractedKeyType(result.getState());

            //it = _map.find(search_key);

            if (_map.ContainsKey(search_key))
            {
                ValueList list = _map[search_key];

                int count = 0;
                while (list != null)
                {
                    // check to see if we are compatible

                    if (SafraTreeCandidateMatcher.isMatch(result, list._key))
                    {
                        //std::cerr << "Found: "<< count << std::endl;
                        return(list._state);
                    }

                    //	std::cerr << "Tree: "<< *list->_tree;

                    list = list._next;
                    count++;
                }
                //      std::cerr << "Not found: "<< count << std::endl;
            }

            // not found
            return(null);
        }
Exemple #3
0
        /**
         * Search for a mapping, fuzzily
         * @param result the query
         * @return the corresponding state or NULL otherwise
         */
        public DA_State find(SafraTreeTemplate result)
        {
            //map_type::const_iterator it;

            AbstractedKeyType search_key = new AbstractedKeyType(result.getState());

            //it = _map.find(search_key);

            if (_map.ContainsKey(search_key))
            {

                ValueList list = _map[search_key];

                int count = 0;
                while (list != null)
                {
                    // check to see if we are compatible

                    if (SafraTreeCandidateMatcher.isMatch(result, list._key))
                    {
                        //std::cerr << "Found: "<< count << std::endl;
                        return list._state;
                    }

                    //	std::cerr << "Tree: "<< *list->_tree;

                    list = list._next;
                    count++;
                }
                //      std::cerr << "Not found: "<< count << std::endl;
            }

            // not found
            return null;
        }
Exemple #4
0
        /**
         * Add a mapping
         * @param key the key
         * @param state the state
         */
        public void add(SafraTree key, DA_State state)
        {
            AbstractedKeyType akey = new AbstractedKeyType(key);
            ValueList list = new ValueList();

            list._key = key;
            list._state = state;
            list._next = null;

            //typename map_type::value_type value (akey, list);

            //std::pair<typename  map_type:: iterator,bool > result = _map.insert(value);

            if (_map.ContainsKey(akey))
            {
                // there is already an element with this structure
                // -> insert list into current list

                ValueList head = _map[akey];
                list._next = head._next;
                head._next = list;

                _map[akey] = head;
            }
            else
            {
                _map.Add(akey, list);
            }

            _count++;
        }