Ejemplo n.º 1
0
void IOComponent::reset() {
	boost::recursive_mutex::scoped_lock lock(processing_queue_mutex);
	processing_queue.clear();
	regular_polls.clear();
	std::list<MachineInstance*>::iterator iter = MachineInstance::begin();
	while (iter != MachineInstance::end()) {
		MachineInstance *m = *iter++;
		if (m->io_interface) { delete m->io_interface; m->io_interface = 0; }
	}
	if (io_process_data) delete[] io_process_data; io_process_data = 0;
	if (io_process_mask) delete[] io_process_mask; io_process_mask = 0;
	if (update_data) delete[] update_data; update_data = 0;
	if (default_data) delete[] default_data; default_data = 0;
	if (default_mask) delete[] default_mask; default_mask = 0;
	if (last_process_data) delete[] last_process_data; last_process_data = 0;
}
Ejemplo n.º 2
0
bool cached_zk::list_(const string& path, std::set<std::string>& out) {
  out.clear();
  struct String_vector s;
  int rc = zoo_wget_children(zh_, path.c_str(), cached_zk::update_cache, this,
                             &s);

  if (rc == ZOK) {
    for (int i = 0; i < s.count; ++i) {
      out.insert(s.data[i]);
    }
    return true;
  } else {
    LOG(ERROR) << "failed to get children: " << path << " - " << zerror(rc);
    return false;
  }
}
Ejemplo n.º 3
0
        void Reset()
        {
            uiCrystalfireBreathTimer = 10*IN_MILLISECONDS;
            uiCrystalChainsTimer = 20*IN_MILLISECONDS;
            uiCrystalizeTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS);
            uiTailSweepTimer = 5*IN_MILLISECONDS;
            bEnrage = false;

            lIntenseColdPlayers.clear();
            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);

            RemovePrison(CheckContainmentSpheres());

            if (pInstance)
                pInstance->SetData(DATA_KERISTRASZA_EVENT, NOT_STARTED);
        }
Ejemplo n.º 4
0
void SparseMatrix<T>::NonZeroRowIndices(std::set<unsigned int>& row_index_set,
                                        const T& epsilon)
{
    row_index_set.clear();

    // save indices of rows with values > epsilon
    for (unsigned int s=0; s<size_; ++s)
    {
        T val = data_[s];
        if (std::abs(val) > epsilon)
        {
            unsigned int row = row_indices_[s];
            row_index_set.insert(row);
        }
    }
}
Ejemplo n.º 5
0
void MeshBase::subdomain_ids (std::set<subdomain_id_type> &ids) const
{
  // This requires an inspection on every processor
  parallel_object_only();

  ids.clear();

  const_element_iterator       el  = this->active_elements_begin();
  const const_element_iterator end = this->active_elements_end();

  for (; el!=end; ++el)
    ids.insert((*el)->subdomain_id());

  // Some subdomains may only live on other processors
  this->comm().set_union(ids);
}
Ejemplo n.º 6
0
static BOOL WINAPI
MyFreeLibrary(HMODULE hModule)
{
    if (VERBOSITY >= 2) {
        debugPrintf("inject: intercepting %s(0x%p)\n", __FUNCTION__, hModule);
    }

    BOOL bRet = FreeLibrary(hModule);

    EnterCriticalSection(&Mutex);
    // TODO: Only clear the modules that have been freed
    g_hHookedModules.clear();
    LeaveCriticalSection(&Mutex);

    return bRet;
}
Ejemplo n.º 7
0
bool ARPScanner::scanLocalNetwork(std::set<std::string>& foundMACAddresses)
{
    FILE *fp;
    int status;
    char line[128];

    std::vector<std::string> lines;

    foundMACAddresses.clear();

    // execute arp-scan
    fp = popen(m_commandString.c_str(), "r");
    if (fp == NULL)
    {
        m_lastErrorString = "cannot execute arp-scan";
        return false;
    }

    // parse arp-scan output
    // address information should start on line 3, ignore first 2
    fgets(line, 128, fp);
    fgets(line, 128, fp);

    // go through rest of the output line by line
    while (fgets(line, 128, fp) != NULL)
    {
        // line's second token should be MAC address
        std::istringstream ss(line);
        std::string MACAddress;
        ss >> MACAddress;
        ss >> MACAddress;

        // after address info there comes some other lines, time to quit
        if (MACAddress == "") break;

        foundMACAddresses.insert(MACAddress);
    }

    status = pclose(fp);
    if (status == -1 || WEXITSTATUS(status) != 0) {
        m_lastErrorString = "cannot execute arp-scan";
        return false;
    }

    m_lastErrorString = "";
    return true;
}
Ejemplo n.º 8
0
void Node::showNode(const std::string &id)
{
    static std::set<std::string> cache;
    auto node = nodeTypeMap[id];
    if (id == "root") cache.clear();
    else {
        if (!cache.count(id))
        {
            cache.insert(id);
            std::cout << "ID: " << id << " Runname: " << node->runname << std::endl;
            std::cout << "Specs: " << std::endl;
            std::cout << "\tParallel level: " << node->paraLevel << std::endl;
            std::cout << "\tChildrens: ";
            for (auto child : node->children)
            {
                std::cout << " " << child.first <<"(";
                switch(child.second)
                {
                    case SHUFFLE:
                    {
                        std::cout << "ShuffleGrouping";
                        break;
                    }

                    case DEFAULT:
                    {
                        std::cout << "DefaultGrouping";
                        break;
                    }
                    default:
                    {
                        std::cout << "Unknown";
                        break;
                    }

                }
                std::cout << ")";
            }
            std::cout << std::endl << std::endl;
        }

    }
    for (auto child : node->children)
    {
        showNode(child.first);
    }
}
        void Initialize()
        {
            memset(&encounter, 0, sizeof(encounter));

            PumpkinShrineGUID  = 0;
            HorsemanGUID = 0;
            HeadGUID = 0;
            HorsemanAdds.clear();

            MograineGUID = 0;
            WhitemaneGUID = 0;
            VorrelGUID = 0;
            DoorHighInquisitorGUID = 0;

            _KelDoor = 0;
            _AsmDoor = 0;
        }
Ejemplo n.º 10
0
void RegEx::Move(char c, std::set<State*> input, std::set<State*>& output)
{
	output.clear();

	set<State*>::iterator it;
	for(it= input.begin();it!= input.end();it++)
	{
		State* u = *it;
		vector<State*> states;
		u->getTransition(c,states);

		for(int i = 0;i<states.size();i++)
		{
			output.insert(states[i]);
		}
	}
}
Ejemplo n.º 11
0
/*
	Privileges
*/
static void read_privileges(lua_State *L, int index,
		std::set<std::string> &result)
{
	result.clear();
	lua_pushnil(L);
	if(index < 0)
		index -= 1;
	while(lua_next(L, index) != 0){
		// key at index -2 and value at index -1
		std::string key = luaL_checkstring(L, -2);
		bool value = lua_toboolean(L, -1);
		if(value)
			result.insert(key);
		// removes value, keeps key for next iteration
		lua_pop(L, 1);
	}
}
Ejemplo n.º 12
0
void split (
  std::set<std::string>& results,
  const std::string& input,
  const char delimiter)
{
  results.clear ();
  std::string::size_type start = 0;
  std::string::size_type i;
  while ((i = input.find (delimiter, start)) != std::string::npos)
  {
    results.insert (input.substr (start, i - start));
    start = i + 1;
  }

  if (input.length ())
    results.insert (input.substr (start));
}
Ejemplo n.º 13
0
    void init()
    {
      fillRace(raceData[RaceIDs::Zerg], "Zerg", UnitTypeIDs::Zerg_Drone, UnitTypeIDs::Zerg_Hatchery, UnitTypeIDs::Zerg_Extractor, UnitTypeIDs::Zerg_Overlord, UnitTypeIDs::Zerg_Overlord);
      fillRace(raceData[RaceIDs::Terran], "Terran", UnitTypeIDs::Terran_SCV, UnitTypeIDs::Terran_Command_Center, UnitTypeIDs::Terran_Refinery, UnitTypeIDs::Terran_Dropship, UnitTypeIDs::Terran_Supply_Depot);
      fillRace(raceData[RaceIDs::Protoss], "Protoss", UnitTypeIDs::Protoss_Probe, UnitTypeIDs::Protoss_Nexus, UnitTypeIDs::Protoss_Assimilator, UnitTypeIDs::Protoss_Shuttle, UnitTypeIDs::Protoss_Pylon);

      raceSet.clear();
      raceSet.insert(RaceIDs::Zerg);
      raceSet.insert(RaceIDs::Terran);
      raceSet.insert(RaceIDs::Protoss);

      raceMap.clear();
      for(std::set<RaceID>::iterator i = raceSet.begin(); i != raceSet.end(); i++)
      {
        raceMap.insert(std::make_pair(std::string(raceData[*i].name), *i));
      }
    }
Ejemplo n.º 14
0
    void Reset()
    {
        reseting = true;
        StartCombat = false;
        HasKilledAkamaAndReseting = false;

        GridSearcherSucceeded = false;

        Sorcerers.clear();
        summons.DespawnAll();//despawn all adds
        Channelers.clear();

        if (Creature* Akama = Unit::GetCreature(*me, AkamaGUID))
        {
            Akama->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);//turn gossip on so players can restart the event
            if (Akama->isDead())
            {
                Akama->Respawn();//respawn akama if dead
                Akama->AI()->EnterEvadeMode();
            }
        }
        SorcererCount = 0;
        DeathCount = 0;

        SummonTimer = 10000;
        ReduceHealthTimer = 0;
        ResetTimer = 60000;
        DefenderTimer = 15000;

        IsBanished = true;
        HasKilledAkama = false;

        me->SetVisible(true);
        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
        //me->GetMotionMaster()->Clear();
        //me->GetMotionMaster()->MoveIdle();
        me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STUN);

        if (pInstance && me->IsAlive())
            pInstance->SetData(DATA_SHADEOFAKAMAEVENT, NOT_STARTED);

        reseting = false;

        me->setActive(true);
    }
Ejemplo n.º 15
0
YK_BOOL CForGantt::GetWorkList(YK_ID resId,YK_TM stTime, YK_TM etTime, std::set<YK_ID>& workLst)
{
	workLst.clear();
	CResCapacitySPtr resCapPtr = g_Application.Get<CResCapacityMap>()->GetResCap(resId);
	if (resCapPtr.ValidObj())
	{
		std::list<YK_ID> tempList;
		resCapPtr->GetAllWorkListInArea(stTime, etTime, tempList);
		for(std::list<YK_ID>::iterator iter = tempList.begin();
			iter != tempList.end();iter++)
		{
			workLst.insert(*iter);
		}
		return true;
	}
	return false;
}
Ejemplo n.º 16
0
		void disconnectall()
		{
			std::set<signal_base*>::iterator it = senders.begin();
			std::set<signal_base*>::iterator end = senders.end();
			std::set<signal_base*>::iterator next;

			while( it != end )
			{
				next = it;
				++next;

				(*it)->disconnect(this);
				it = next;
			}

			senders.clear();
		}
Ejemplo n.º 17
0
	CondensationOut build_condensation() {
		std::vector< Vertex > top_sort = topological_sort();
		
		in_sort.clear();
		out_sort.clear();
		used.clear();
		cond.clear();
		for (auto v = top_sort.rbegin(); v != top_sort.rend(); ++v) {
			if (used.find(v) == used.end()) {
				this->dfs< Transposed >(v);
				cond.push_back(vSet(in_sort.begin(), in_sort.end()));
				in_sort.clear();
			}
		}
	
		return cond;
	}
Ejemplo n.º 18
0
/*
 * Search object in database using its key
 * \param key is the 64 bits row key to search through all tables
 */
bool	CDatabase::searchObjectIndex(uint64 key, std::set<RY_PDS::CObjectIndex>& indexes) const
{
	indexes.clear();

	uint	i;
	for (i=0; i<_Tables.size(); ++i)
	{
		if (_Tables[i] == NULL || !_Tables[i]->initialised() || !_Tables[i]->isMapped())
			continue;

		RY_PDS::CObjectIndex	index = _Tables[i]->getMappedRow(key);

		if (index.isValid())
			indexes.insert(index);
	}

	return !indexes.empty();
}
Ejemplo n.º 19
0
        void Reset()
        {
            uiCrystalfireBreathTimer = 14*IN_MILLISECONDS;
            uiCrystalChainsCrystalizeTimer = DUNGEON_MODE(30*IN_MILLISECONDS,11*IN_MILLISECONDS);
            uiTailSweepTimer = 5*IN_MILLISECONDS;
            bEnrage = false;

            uiCheckIntenseColdTimer = 2*IN_MILLISECONDS;
            //bMoreThanTwoIntenseCold = false;
            lMoreThanTwoIntenseCold.clear();

            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);

            RemovePrison(CheckContainmentSpheres());

            if (pInstance)
                pInstance->SetData(DATA_KERISTRASZA_EVENT, NOT_STARTED);
        }
Ejemplo n.º 20
0
static void ParseExtensionsString(const std::string& str, std::set<std::string> &output) {
	output.clear();

	size_t next = 0;
	for (size_t pos = 0, len = str.length(); pos < len; ++pos) {
		if (str[pos] == ' ') {
			output.insert(str.substr(next, pos - next));
			// Skip the delimiter itself.
			next = pos + 1;
		}
	}

	if (next == 0 && str.length() != 0) {
		output.insert(str);
	} else if (next < str.length()) {
		output.insert(str.substr(next));
	}
}
Ejemplo n.º 21
0
void NTriangulation::maximalForestInSkeleton(std::set<NEdge*>& edgeSet,
        bool canJoinBoundaries) const {
    ensureSkeleton();

    std::set<NVertex*> vertexSet;
    std::set<NVertex*> thisBranch;

    if (canJoinBoundaries)
        edgeSet.clear();
    else
        maximalForestInBoundary(edgeSet, vertexSet);

    for (NVertex* v : vertices())
        if (! (vertexSet.count(v))) {
            stretchForestFromVertex(v, edgeSet, vertexSet, thisBranch);
            thisBranch.clear();
        }
}
Ejemplo n.º 22
0
void ZTBSpec::GetPropNames(std::set<std::string>& oPropNames) const
	{
	oPropNames.clear();
	if (!fRep)
		return;

	for (CriterionUnion::const_iterator outer = fRep->fCriterionUnion.begin(),
		outerEnd = fRep->fCriterionUnion.end();
		outer != outerEnd; ++outer)
		{
		for (CriterionSect::const_iterator inner = (*outer).begin(), innerEnd = (*outer).end();
			inner != innerEnd;
			++inner)
			{
			oPropNames.insert((*inner).GetPropName().AsString());
			}
		}
	}
Ejemplo n.º 23
0
void ZTBSpec::GetPropNames(std::set<ZTuplePropName>& oPropNames) const
	{
	oPropNames.clear();
	if (!fRep)
		return;

	for (CriterionUnion::const_iterator outer = fRep->fCriterionUnion.begin(),
		outerEnd = fRep->fCriterionUnion.end();
		outer != outerEnd; ++outer)
		{
		for (CriterionSect::const_iterator inner = outer->begin(), innerEnd = outer->end();
			inner != innerEnd;
			++inner)
			{
			oPropNames.insert(inner->GetPropName());
			}
		}
	}
Ejemplo n.º 24
0
bool ReadSubcriberFile(const std::string& dir, const std::string& filename, std::set<uint16_t>& subscribers) {
  subscribers.clear();

  TextFile file(dir, filename, "rt");
  if (!file.IsOpen()) {
    return false;
  }

  string line;
  while (file.ReadLine(&line)) {
    StringTrim(&line);
    uint16_t s = StringToUnsignedShort(line);
    if (s > 0) {
      subscribers.insert(s);
    }
  }
  return true;
}
Ejemplo n.º 25
0
void
IKeyState::KeyInfo::split(const char* screens, std::set<String>& dst)
{
	dst.clear();
	if (isDefault(screens)) {
		return;
	}
	if (screens[0] == '*') {
		dst.insert("*");
		return;
	}

	const char* i = screens + 1;
	while (*i != '\0') {
		const char* j = strchr(i, ':');
		dst.insert(String(i, j - i));
		i = j + 1;
	}
}
Ejemplo n.º 26
0
void new_code_line (string_pos n, std::string& new_code)
{
	if (new_instanciations.size() > 0)
	{
		for (std::set<std::string>::iterator i = new_instanciations.begin(); i != new_instanciations.end(); ++i)
		{
			new_code_lines.push_back (*i);
		}
	}

	new_code_lines.push_back (new_code);
	new_code = "";

	previous_line_start = n;
	if (n > 0)
		n--;

	new_instanciations.clear();
}
Ejemplo n.º 27
0
void Data<Annotation>::set_union(
  std::set<Data<Annotation> *> & result_,
  const std::set<Data<Annotation> *> & datas_
) {
  // FIXME currently: same symbol => same data

  std::vector<Data<Annotation> *> datas(datas_.begin(), datas_.end());
  std::vector<Data<Annotation> *> result_in (result_.begin(), result_.end());
  std::vector<Data<Annotation> *> result_out(result_.size() + datas.size());

  std::sort(result_in.begin(), result_in.end(), less);
  std::sort(datas.begin(), datas.end(), less);

  typename std::vector<Data<Annotation> *>::iterator it_result_begin = result_out.begin();
  typename std::vector<Data<Annotation> *>::iterator it_result_end = std::set_union(result_in.begin(), result_in.end(), datas.begin(), datas.end(), it_result_begin, less);

  result_.clear();
  result_.insert(it_result_begin, it_result_end);
}
Ejemplo n.º 28
0
inline void computeStrongNeighbors(const double delta, const std::vector<double>& max_aff, const SpMat& C, std::set<size_t>& strongNeighbors) {
    strongNeighbors.clear();
    for (size_t u = 0; u < C.rows(); u++) {
        for (SpMat::ConstIterator v = C.begin(u); v != C.end(u); v++) {
            if (v->index() <= u) //guardo solo il triangolo superiore, senza diagonale
                continue;
            //v->value() è c_uv
            //max_aff[u] è max{s!=u} c_us
            //max_aff[v->index()] è max{s!=v} c_sv
            //Quindi se c_uv >= delta*max{ max{s!=u} c_us, max{s!=v} c_sv}
            if (v->value() >= delta * max(max_aff[u], max_aff[v->index()])) {
                // u e v sono strong neighbors, li metto nel set

                strongNeighbors.insert(u);
                strongNeighbors.insert(v->index());
            }
        }
    }
}
Ejemplo n.º 29
0
void writeNodeIconSection(std::ostream& out, NodeSet& ns, Config& config)
{
    iconNames.clear();
    NodeSet::iterator it = ns.begin();
    while (it != ns.end())
    {
        EntityTypeStruct type = (*it)->entity->entityType;
        const std::string& icon = (*it)->getIconName();
        if (!icon.empty())
        {
            std::string filename = config.getFileName(icon);
            out << "[" << (*it)->NodeId << "] NODE-ICON";
            out << "\t\ticons" << config.dirSep << filename << std::endl;
            iconNames.insert(icon);
        }
        it++;
    }
    out << std::endl;
}
Ejemplo n.º 30
0
bool
CTrieMaker::parseLine(char* buf,
          char* word_buf,
          unsigned& id,
          std::set<TUnitInfo>& unitset)
{
    unitset.clear();

    /* ignore the empty lines and comment lines */
    if (*buf == '\n' || *buf == '#')
        return 0;

    char* p = (char*)skipSpace(buf);
    char* t = (char*)skipNonSpace(p);
    while (p < t) *word_buf++ = *p++;
    *word_buf = 0;

    p = (char*)skipSpace(p);
    t = (char*)skipNonSpace(p);
    if (*t)
        *t++ = 0;
    id = atoi(p);
    p = (char*)skipSpace(t);
    while (*p) {
        const char* s = p;
        t = (char*)skipNonSpace(p);
        if (*t)
            *t++ = 0;
        while ((*p >= 'a' && *p <= 'z') || (*p == '\''))
            ++p;
        if ((p > s) && ((*p == 0) || (*p == ':'))) {
            int cost = 0;
            if (*p == ':') {
                *p++ = 0;
                cost = -log2(atof(p)/100);
            }
            unitset.insert(TUnitInfo(s, cost));
        }
        p = (char*)skipSpace(t);
    }
    return unitset.size() > 0;
}