Example #1
0
void SymTab::insert( Index name, SymInfo a )
{
	pair< iterator, bool >ele = symbolList.insert( SymTabEntry( name, a ) );
	SymInfo &var = ( *ele.first ).second;
	const unsigned int pos = name.find( "." );;
	if ( pos != string::npos ) {
		name.erase( pos );
		var.makLocal( );
	}

	var.modName( name );
	var.modValue( name );
	var.nameSet = true;
}
Example #2
0
    void remove(File const &file)
    {
        DENG2_GUARD_WRITE(this);

        if(index.empty())
        {
            return;
        }

        // Look up the ones that might be this file.
        IndexRange range = index.equal_range(indexedName(file));

        for(Index::iterator i = range.first; i != range.second; ++i)
        {
            if(i->second == &file)
            {
                // This is the one to deindex.
                index.erase(i);
                break;
            }
        }
    }
Example #3
0
void UserFeedSet::_buildFeedContents(Index& index, std::vector<
    typename Index::iterator>& itSeq, FeedDataSeq& seq) {
  MCE_DEBUG("UserFeedSet::BuildFeedContents --> iterator.size:"<< itSeq.size()<< ", ContentSeq.size:"<<seq.size());
  MyUtil::LongSeq fids;
  for (typename std::vector<typename Index::iterator>::iterator it =
      itSeq.begin(); it != itSeq.end(); ++it) {
    MyUtil::LongSeq ids = (**it)->getFeedIdSeq();//查找这个MergeGroup所有的feedid
    fids.insert(fids.end(), ids.begin(), ids.end());
  }
  if (fids.empty()) {
    return;
  }
  FeedContentDict fdict = FeedContentAdapter::instance().getFeedDict(fids);//根据feedid查找feedcontent
  MCE_DEBUG("_buildFeedContents --> get FeedContent content.size:"<<fdict.size());
  for (typename std::vector<typename Index::iterator>::iterator wit =
      itSeq.begin(); wit != itSeq.end(); ++wit) {
    FeedSeq feedSeq = (**wit)->get();
    if (feedSeq.size() == 1) { //这个MergeGroup只有一个feed
      FeedContentDict::iterator it = fdict.find(feedSeq.at(0)->feed);
      if (it != fdict.end()) {
        if (it->second) {
          //因为feed_content表中的type为负时会为0,所以需要重新负一下值
          it->second->data->type = feedSeq.at(0)->type;
          //------

          ostringstream xml;
          xml << it->second->data->xml;
          if (it->second->reply) {
            xml << it->second->reply->oldReply << it->second->reply->newReply
                << "<reply_count>" << it->second->reply->count
                << "</reply_count>";
            it->second->reply = 0;
          }

          it->second->data->xml = xml.str();
          seq.push_back(it->second->data);
          //TODO do feedback
          //            MCE_DEBUG("_buildFeedContents --> weight:"<< it->second->data->weight << "  file:"<<__FILE__<<" line:"<<__LINE__);
          //            feedSeq.at(0)->setWeight(it->second->data->weight);
          //            MCE_DEBUG("_buildFeedContents  weight:"<<(it->second->data->weight & 0x0000ffff));
          //            if ((**wit)->updateWeight()) {
          //              index.replace(*wit, **wit);
          //            };
          //----
        } else {
          (**wit)->remove(it->first);
          if ((**wit)->empty()) {
            index.erase(*wit);
          }
        }
      }

    } else if (feedSeq.size() > 1) { //MergeGroup有多个feed
      FeedDataPtr data;
      FeedReplyPtr reply;
      ostringstream xml;
      for (size_t i = 0; i < feedSeq.size(); ++i) {
        Ice::Long fid = feedSeq.at(i)->feed;
        FeedContentDict::iterator it = fdict.find(fid);
        if (it == fdict.end()) {
          continue;
        }

        if (!it->second) { //FeedContentDict没有feedid对应的FeedData和FeedReply
          (**wit)->remove(it->first);
          if ((**wit)->empty()) {
            index.erase(*wit);
          }
          continue;
        }

        //          feedSeq.at(i)->setWeight(it->second->data->weight);
        if (!data) { //FeedDataPtr没有被赋值
          data = it->second->data;
          reply = it->second->reply;
          //TODO do feedback
          //            if ((**wit)->updateWeight()) {
          //              index.replace(*wit, **wit);
          //            };
          //---
        }

        //          MCE_DEBUG("xml:"<<it->second->data->xml);
        xml << it->second->data->xml; //拼接xml
      }
      if (data) {
        if (reply) {
          xml << reply->oldReply << reply->newReply << "<reply_count>"
              << reply->count << "</reply_count>";
        }
        data->xml = xml.str();
        seq.push_back(data);
      }

    }

  }

}
Example #4
0
 typename enable_if<
     is_associative_container<Index>, void
 >::type operator()(Index & x) const
 {
     x.erase(x.iterator_to(value));
 }
Example #5
0
// infer until fixpoint, which may not be appropriate in the presence of retraction
void infer(vector<Rule> &rules) {
  bool changed = true;
  map<constint_t, size_t> sizes;
  map<constint_t, Index>::const_iterator atomit = atoms.begin();
  for (; atomit != atoms.end(); ++atomit) {
    sizes[atomit->first] = atomit->second.size();
  }
  size_t ncycles = 0;
  while (changed) {
    cerr << "  Cycle " << ++ncycles << "..." << endl;
    changed = false;
#ifndef ANY_ORDER
    Index assertions (Order(0, 1, 2));
    Index retractions (Order(0, 1, 2));
#endif
    int rulecount = 0;
    vector<Rule>::iterator rule = rules.begin();
    for (; rule != rules.end(); ++rule) {
      cerr << "    Rule " << (rule - rules.begin()) + 1 << "..." << endl;
#ifdef ANY_ORDER
      Index assertions (Order(0, 1, 2));
      Index retractions (Order(0, 1, 2));
#endif
      Relation results;
      set<varint_t> allvars;
      query(rule->condition, allvars, results);
      act(rule->action_block, results, assertions, retractions);
#ifndef ANY_ORDER
    }
#endif
    size_t nretractions = 0;
    Index::iterator it = retractions.begin();
    for (; it != retractions.end(); ++it) {
      if (idxspo.erase(*it) > 0) {
        idxpos.erase(*it);
        idxosp.erase(*it);
        changed = true;
        ++nretractions;
      }
    }
    cerr << "  " << nretractions << " retractions, ";
    size_t nassertions = 0;
    it = assertions.begin();
    for (; it != assertions.end(); ++it) {
      if (idxspo.insert(*it).second) {
        idxpos.insert(*it);
        idxosp.insert(*it);
        changed = true;
        ++nassertions;
      }
    }
    cerr << nassertions << " assertions." << endl;
#ifdef ANY_ORDER
    }
#endif
    atomit = atoms.begin();
    for (; atomit != atoms.end(); ++atomit) {
      changed = changed || sizes[atomit->first] != atomit->second.size();
      sizes[atomit->first] = atomit->second.size();
    }
  }