当前位置: 首页>>代码示例>>C++>>正文


C++ Connections类代码示例

本文整理汇总了C++中Connections的典型用法代码示例。如果您正苦于以下问题:C++ Connections类的具体用法?C++ Connections怎么用?C++ Connections使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Connections类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    if (qApp->arguments().indexOf(QRegExp("-help"))!=-1 || qApp->arguments().length()==1) {
            qDebug() << "bundler (-nodes <nodes> -cons <connections> / -fib <.fib-file>) [-c_thr <compatibility threshold>] [-start_i <iterations in 1st cycle>] [-numcycles <number of cycles>]";
            return 1;
    }

    qDebug() << "nodesname: " + arg("nodes");
    qDebug() << "consname: " + arg("cons");
    Connections* cons;
    if (arg("cons")!="") {
        cons = new Connections(arg("nodes"),arg("cons"));
    } else if (arg("fib")!="") {
        cons = new Connections(arg("fib"));
    } else {
        qDebug() << "no dataset given";
        return 0;
    }

    if (arg("c_thr")!="") cons->c_thr = arg("c_thr").toDouble();
    if (arg("start_i")!="") cons->start_i = arg("start_i").toInt();
    if (arg("numcycles")!="") cons->numcycles = arg("numcycles").toInt();

    qDebug() << cons->name();

    cons->fullAttract();
    if (arg("out")!="") {
        cons->writeBinaryVTK(arg("out"));
    } else {
        cons->writeBinaryVTK();
    }
    return 1;
}
开发者ID:satra,项目名称:brainbundler,代码行数:35,代码来源:main.cpp

示例2: getConnections

void P2PConnectionsWindow::refreshConnections()
{
	Connections connections;
	// Effettua una copia per evitare una lock durante il check
	getConnections(connections);

	wxWindowUpdateLocker windowLocker(m_connectionsCtrl);

	uint32 connectionsCount = static_cast<uint32>(connections.size());
	uint32 connectionsLimit = getConnectionsLimit();

	bool pendingRefresh = false;

	for(Connections::iterator i = connections.begin(); i != connections.end(); ++i)
	{
		if(i->second->getRemoved())
		{
			if(i->second->isElapsed() || (connectionsCount > connectionsLimit))
			{
				doRemoveConnection(i->first);
				connectionsCount--;
			}
			else
			{
				markConnectionRemoved(i->first);
			}
		}
		else
		{
			refreshConnectionItem(i->first);
		}
	}
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: memcpy

bool Connection::send( const Connections& connections, Packet& packet,
                       const void* data, const uint64_t dataSize,
                       const bool isLocked )
{
    if( connections.empty( ))
        return true;

    if( dataSize <= 8 ) // fits in existing packet
    {
        if( dataSize != 0 )
            memcpy( (char*)(&packet) + packet.size-8, data, dataSize );
        return send( connections, packet, isLocked );
    }

    const uint64_t headerSize  = packet.size - 8;
    const uint64_t size        = headerSize + dataSize;

    if( size > EQ_ASSEMBLE_THRESHOLD )
    {
        // OPT: lock the connection and use two send() to avoid big memcpy
        packet.size = size;
        bool success = true;

        for( Connections::const_iterator i= connections.begin(); 
             i<connections.end(); ++i )
        {        
            ConnectionPtr connection = *i;

            if( !isLocked )
                connection->lockSend();

            if( !connection->send( &packet, headerSize, true ) ||
                !connection->send( data, dataSize, true ))
            {
                success = false;
            }
            if( !isLocked )
                connection->unlockSend();    
        }
        return success;
    }

    char*          buffer = (char*)alloca( size );
    memcpy( buffer, &packet, packet.size-8 );
    memcpy( buffer + packet.size-8, data, dataSize );

    ((Packet*)buffer)->size = size;

    bool success = true;
    for( Connections::const_iterator i = connections.begin(); 
         i < connections.end(); ++i )
    {        
        ConnectionPtr connection = *i;
        if( !connection->send( buffer, size, isLocked ))
            success = false;
    }

    return success;
}
开发者ID:cstalder,项目名称:Equalizer,代码行数:59,代码来源:connection.cpp

示例4: connections

/// Get connection by owner instance (0=ALL)
StagedIODataManager::Connections StagedIODataManager::connections(const IInterface* owner) const {
  Connections conns;
  for(ConnectionMap::const_iterator i=m_connectionMap.begin(); i!=m_connectionMap.end();++i) {
    IDataConnection* c = (*i).second->connection;
    if ( 0 == owner || c->owner() == owner )
      conns.push_back(c);
  }
  return conns;

}
开发者ID:remenska,项目名称:Gaudi-FileStager,代码行数:11,代码来源:StagedIODataManager.cpp

示例5: Block

	 void Block(const std::string& signalnamespace){
		//matching namespace? don't block global (non-namespaced) signals
		if(signalnamespace == this->signalnamespace && this->signalnamespace != ""){
			//signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output",
			//	"SignalSubsriber<" + childname + ">::Block("+this->signalnamespace+")");

			Connections::iterator itr = connections.begin();
			for(; itr!= connections.end(); itr++){
				itr->second.block();
			}
		}
	}
开发者ID:chikanamakalaka,项目名称:pacman-sdl,代码行数:12,代码来源:SignalSubscriber.hpp

示例6: Thread

void ConnectionSet::_createThread( const Connections& connections )
{
    Thread* thread = new Thread( this );
    for ( ConnectionsCIter it = connections.begin(); 
          it != connections.end(); 
          ++it )
    {
        ConnectionPtr connection = *it;
        thread->set.addConnection( connection );
    }

    _impl->threads.push_back( thread );
    thread->start();
}
开发者ID:rttag,项目名称:Collage,代码行数:14,代码来源:connectionSet.cpp

示例7: createBlockRow

            void
            createBlockRow(size_t i, const Connections& conn, size_t ndof) {
                assert (ndof == 1);            (void) ndof;
                assert (i    == i_prev_ + 1);  (void) i   ;

                ISTLTypeDetails::ScalarBCRSMatrix::CreateIterator ci(mat_, i);

                for (typename Connections::const_iterator
                         c = conn.begin(), e = conn.end(); c != e; ++c) {
                    ci.insert(*c);
                }

                ++i_prev_;
                ++ci;
            }
开发者ID:akva2,项目名称:opm-porsol,代码行数:15,代码来源:BCRSMatrixBlockAssembler.hpp

示例8: send

bool Connection::send( const Connections& connections,
                       const Packet& packet, const bool isLocked )
{
    if( connections.empty( ))
        return true;

    bool success = true;
    for( Connections::const_iterator i= connections.begin(); 
         i<connections.end(); ++i )
    {        
        ConnectionPtr connection = *i;
        if( !connection->send( &packet, packet.size, isLocked ))
            success = false;
    }
    return success;
}
开发者ID:cstalder,项目名称:Equalizer,代码行数:16,代码来源:connection.cpp

示例9: removeFromConnectionTable

void removeFromConnectionTable(int socketDescriptor){
	/* Remove the user with the closed socket */
	Connections::iterator it = conn.begin();
	while(it!=conn.end()){
		if(it->second == socketDescriptor){
			
			#ifdef __INFO__
			std::cout<<"\""<<it->first<<"\" went offline on socket "<<socketDescriptor<<"."<<std::endl;
			#endif

			conn.erase(it);
			break;
		}
		++it;
	}
}
开发者ID:ChinmayJindal,项目名称:GossipBox,代码行数:16,代码来源:Server.cpp

示例10: adaptSegment

static void adaptSegment(
  Connections& connections,
  Segment segment,
  const vector<CellIdx>& prevActiveCells,
  Permanence permanenceIncrement,
  Permanence permanenceDecrement)
{
  const vector<Synapse>& synapses = connections.synapsesForSegment(segment);

  for (SynapseIdx i = 0; i < synapses.size();)
  {
    const SynapseData& synapseData = connections.dataForSynapse(synapses[i]);
    const bool isActive =
      std::binary_search(prevActiveCells.begin(), prevActiveCells.end(),
                         synapseData.presynapticCell);
    Permanence permanence = synapseData.permanence;

    if (isActive)
    {
      permanence += permanenceIncrement;
    }
    else
    {
      permanence -= permanenceDecrement;
    }

    permanence = min(permanence, (Permanence)1.0);
    permanence = max(permanence, (Permanence)0.0);

    if (permanence < EPSILON)
    {
      connections.destroySynapse(synapses[i]);
      // Synapses vector is modified in-place, so don't update `i`.
    }
    else
    {
      connections.updateSynapsePermanence(synapses[i], permanence);
      i++;
    }
  }

  if (synapses.size() == 0)
  {
    connections.destroySegment(segment);
  }
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例11: getOnlineList

/* 
 * Returns list of online nicknames as
 * ONLINE: <user1> : <user2> : ...
 */
std::string getOnlineList(std::string curUser){
	std::string response = "ONLINE: ";
	Connections::iterator it = conn.begin();

	while(it!=conn.end()){
		if(it->first!=curUser){
			bool online = isOnline(it->first);
			if(online){
				response += it->first;
				response += ":";
			}
		}
		++it;
	}

	return response;
}
开发者ID:ChinmayJindal,项目名称:GossipBox,代码行数:21,代码来源:Server.cpp

示例12: getLeastUsedCell

static CellIdx getLeastUsedCell(
  Random& rng,
  UInt column,
  const Connections& connections,
  UInt cellsPerColumn)
{
  const CellIdx start = column * cellsPerColumn;
  const CellIdx end = start + cellsPerColumn;

  UInt32 minNumSegments = UINT_MAX;
  UInt32 numTiedCells = 0;
  for (CellIdx cell = start; cell < end; cell++)
  {
    const UInt32 numSegments = connections.numSegments(cell);
    if (numSegments < minNumSegments)
    {
      minNumSegments = numSegments;
      numTiedCells = 1;
    }
    else if (numSegments == minNumSegments)
    {
      numTiedCells++;
    }
  }

  const UInt32 tieWinnerIndex = rng.getUInt32(numTiedCells);

  UInt32 tieIndex = 0;
  for (CellIdx cell = start; cell < end; cell++)
  {
    if (connections.numSegments(cell) == minNumSegments)
    {
      if (tieIndex == tieWinnerIndex)
      {
        return cell;
      }
      else
      {
        tieIndex++;
      }
    }
  }

  NTA_THROW << "getLeastUsedCell failed to find a cell";
}
开发者ID:,项目名称:,代码行数:45,代码来源:

示例13: AddConnection

	boost::signals::connection AddConnection(const std::string& name, boost::signals::connection connection){
		connections.insert(Connections::value_type(name, connection));

		//block if signalbroker says so, but do not block global signals
		if(signalbroker.IsBlocked(signalnamespace) && signalnamespace != ""){
			connection.block();
		}
		return connection;
	}
开发者ID:chikanamakalaka,项目名称:pacman-sdl,代码行数:9,代码来源:SignalSubscriber.hpp

示例14: addToConnectionTable

void addToConnectionTable(std::string username, int socketDescriptor){
	std::pair<Connections::iterator,bool> retVal = conn.insert(std::make_pair(username, socketDescriptor));
	/* Update if key already exists to new socket Descriptor */
	if(!retVal.second){
		retVal.first->second = socketDescriptor;
	}
	#ifdef __INFO__
	std::cout<<"New user \""<<username<<"\" on socket "<<socketDescriptor<<"."<<std::endl;
	#endif
}
开发者ID:ChinmayJindal,项目名称:GossipBox,代码行数:10,代码来源:Server.cpp

示例15: growSynapses

static void growSynapses(
  Connections& connections,
  Random& rng,
  Segment segment,
  UInt32 nDesiredNewSynapses,
  const vector<CellIdx>& prevWinnerCells,
  Permanence initialPermanence)
{
  // It's possible to optimize this, swapping candidates to the end as
  // they're used. But this is awkward to mimic in other
  // implementations, especially because it requires iterating over
  // the existing synapses in a particular order.

  vector<CellIdx> candidates(prevWinnerCells.begin(), prevWinnerCells.end());
  NTA_ASSERT(std::is_sorted(candidates.begin(), candidates.end()));

  // Remove cells that are already synapsed on by this segment
  for (Synapse synapse : connections.synapsesForSegment(segment))
  {
    CellIdx presynapticCell =
      connections.dataForSynapse(synapse).presynapticCell;
    auto ineligible = std::lower_bound(candidates.begin(), candidates.end(),
                                       presynapticCell);
    if (ineligible != candidates.end() && *ineligible == presynapticCell)
    {
      candidates.erase(ineligible);
    }
  }

  const UInt32 nActual = std::min(nDesiredNewSynapses,
                                  (UInt32)candidates.size());

  // Pick nActual cells randomly.
  for (UInt32 c = 0; c < nActual; c++)
  {
    size_t i = rng.getUInt32(candidates.size());
    connections.createSynapse(segment, candidates[i], initialPermanence);
    candidates.erase(candidates.begin() + i);
  }
}
开发者ID:,项目名称:,代码行数:40,代码来源:


注:本文中的Connections类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。