コード例 #1
0
void test<CONTAINER,HANDLER>::iterate(unsigned count, bool warm, bool write)
{
  CONTAINER container;
  unsigned unused = 0;
  for(unsigned ii = 0; ii != count; ++ii)
    container.push_back(ii);
  if (warm) {
    for(typename CONTAINER::const_iterator iter = container.begin();
        iter != container.end();
        ++iter)
    {
      unused += *iter;
    }
  }
  boost::timer::cpu_timer timer;
  timer.start();
  for(typename CONTAINER::const_iterator iter = container.begin();
      iter != container.end();
      ++iter)
  {
    unused += *iter;
  }
  timer.stop();
  if (unused == 1234) { // won't happen
    std::cout << "YEAH RIGHT!";
  }
  if (write) {
    dump(timer, "iterate", count, warm);
  }
}
コード例 #2
0
void test<CONTAINER,HANDLER>::insert(unsigned count, bool warm, bool write)
{
  CONTAINER container;
  if (warm) {
    container.push_back(0); container.push_back(0);
    typename CONTAINER::iterator iter = ++container.begin();
    for(unsigned ii = 0; ii != count; ++ii) {
      iter = _handler.insert(container, iter, 1);
      if (ii & 1) ++iter;
    }
    container.clear();
  }
  container.push_back(0); container.push_back(0);
  boost::timer::cpu_timer timer;
  timer.start();
  typename CONTAINER::iterator iter = ++container.begin();
  for(unsigned ii = 0; ii != count; ++ii) {
    iter = _handler.insert(container, iter, 1);
    if (ii & 1) ++iter;
  }
  timer.stop();
  if (write) {
    dump(timer, "middle insert", count, warm);
  }
}
コード例 #3
0
ファイル: utilities.hpp プロジェクト: cwbaker/sweet_persist
bool compare_map_pointers( const CONTAINER& lhs, const CONTAINER& rhs )
{
    typename CONTAINER::const_iterator i = lhs.begin();
    typename CONTAINER::const_iterator j = rhs.begin();
    while ( i != lhs.end() && j != rhs.end() && i->first == j->first && (i->second == 0 && j->second == 0 || i->second != 0 && j->second != 0 && *i->second == *j->second) )
    {
        ++i;
        ++j;
    }

    return i == lhs.end() && j == rhs.end();
}
コード例 #4
0
ファイル: utilities.hpp プロジェクト: cwbaker/sweet_persist
bool compare( const CONTAINER& lhs, const CONTAINER& rhs )
{
    typename CONTAINER::const_iterator i = lhs.begin();
    typename CONTAINER::const_iterator j = rhs.begin();
    while ( i != lhs.end() && j != rhs.end() && *i == *j )
    {
        ++i;
        ++j;
    }

    return i == lhs.end() && j == rhs.end();
}
コード例 #5
0
ファイル: utilities.hpp プロジェクト: cwbaker/sweet_persist
bool compare_map_weak_ptrs( const CONTAINER& lhs, const CONTAINER& rhs )
{
    typename CONTAINER::const_iterator i = lhs.begin();
    typename CONTAINER::const_iterator j = rhs.begin();
    while ( i != lhs.end() && j != rhs.end() && (i->second.lock().get() == 0 && j->second.lock().get() == 0 || i->second.lock() != 0 && j->second.lock() != 0 && *(i->second.lock()) == *(j->second.lock())) )
    {
        ++i;
        ++j;
    }

    return i == lhs.end() && j == rhs.end();
}
コード例 #6
0
ファイル: utilities.hpp プロジェクト: cwbaker/sweet_persist
bool compare_pointer_types( const CONTAINER& lhs, const CONTAINER& rhs )
{
    typename CONTAINER::const_iterator i = lhs.begin();
    typename CONTAINER::const_iterator j = rhs.begin();
    while ( i != lhs.end() && j != rhs.end() && (*i == 0 && *j == 0 || *i != 0 && *j != 0 && (*(*i) == *(*j) && SWEET_TYPEID(*(*i)) == SWEET_TYPEID(*(*j)))) )
    {
        ++i;
        ++j;
    }

    return i == lhs.end() && j == rhs.end();
}
コード例 #7
0
ファイル: utilities.hpp プロジェクト: cwbaker/sweet_persist
bool 
compare_container_of_containers( const CONTAINER& lhs, const CONTAINER& rhs )
{
    typename CONTAINER::const_iterator i = lhs.begin();
    typename CONTAINER::const_iterator j = rhs.begin();
    while ( i != lhs.end() && j != rhs.end() && compare(*i, *j) )
    {
        ++i;
        ++j;
    }

    return i == lhs.end() && j == rhs.end();
}
コード例 #8
0
ファイル: main.cpp プロジェクト: CCJY/coliru
template< typename CONTAINER > std::clock_t geminate( CONTAINER& cntr )
{
    const auto start = std::clock() ;
    for( auto iter = cntr.begin() ; iter != cntr.end() ; ++iter, ++iter )
        iter = cntr.insert( iter, *iter ) ;
    return std::clock() - start ;
}
コード例 #9
0
ファイル: Caching_Utility_T.cpp プロジェクト: 1ATOM/mangos
template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (CONTAINER &container,
                                                                                KEY *&key_to_remove,
                                                                                VALUE *&value_to_remove)
{
  // Starting values.
  ITERATOR iter = container.begin ();
  ITERATOR end = container.end ();
  ATTRIBUTES min = (*iter).int_id_.second ();
  key_to_remove = &(*iter).ext_id_;
  value_to_remove = &(*iter).int_id_;

  // The iterator moves thru the container searching for the entry
  // with the lowest ATTRIBUTES.
  for (++iter;
       iter != end;
       ++iter)
    {
      if (min > (*iter).int_id_.second ())
        {
          // Ah! an item with lower ATTTRIBUTES...
          min = (*iter).int_id_.second ();
          key_to_remove = &(*iter).ext_id_;
          value_to_remove = &(*iter).int_id_;
        }
    }
}
コード例 #10
0
ファイル: HazardModule.cpp プロジェクト: aronarts/FireNET
void HazardModule::RemoveExpiredHazardsHelperProcessContainer(CONTAINER& container)
{
	// NOTE: in the future we may want to keep the array sorted based on
	// expiry time or something.
	const float nowTimeIndex = gEnv->pTimer->GetCurrTime();
	bool expiredFlag = false;
	typename CONTAINER::iterator iter = container.begin();
	while (iter != container.end())
	{
		expiredFlag = false;
		if (iter->GetExpireTimeIndex() >= 0)
		{
			if (iter->GetExpireTimeIndex() <= nowTimeIndex)
			{
				expiredFlag = true;
			}
		}

		if (expiredFlag)
		{
			iter = ExpireAndDeleteHazardInstance(container, iter);	
			expiredFlag = false;
		}
		else
		{
			++iter;
		}
	}	
}
コード例 #11
0
ファイル: HazardModule.cpp プロジェクト: aronarts/FireNET
void HazardModule::ProcessCollisionsWithEntityProcessContainer(
	CONTAINER& container, Agent& agent,
	const char *signalFunctionName, const EntityId entityID)
{
	assert(signalFunctionName != NULL);
	
	HazardCollisionResult collisionResult;

	// NOTE: for now this will be quick and dirty. If the amount of hazards
	// becomes too big we should apply some spatial hashing schemes!
	typename CONTAINER::const_iterator hazardIter;
	typename CONTAINER::const_iterator hazardEndIter = container.end();
	for (hazardIter = container.begin() ; hazardIter != hazardEndIter ; ++hazardIter)
	{
		if (hazardIter->ShouldWarnEntityID(entityID))		
		{
			hazardIter->CheckCollision(agent, &collisionResult);
			if (collisionResult.m_CollisionFlag)			
			{
				if (hazardIter->IsAgentAwareOfDanger(agent, collisionResult.m_HazardOriginPos))
				{
					SendSignalToAgent(agent, signalFunctionName, 
						collisionResult.m_HazardOriginPos, hazardIter->GetNormal());
				}
			}
		}
	}
}
コード例 #12
0
ファイル: HazardModule.cpp プロジェクト: aronarts/FireNET
void HazardModule::PurgeAllHazardsProcessContainer(CONTAINER& container)
{
	typename CONTAINER::iterator iter = container.begin();
	while (iter != container.end())
	{
		iter = ExpireAndDeleteHazardInstance(container, iter);
	}
}
コード例 #13
0
ファイル: HazardModule.cpp プロジェクト: aronarts/FireNET
void HazardModule::StartRequestedRayCastsProcessContainer(CONTAINER& container)
{
	typename CONTAINER::iterator iter;
	typename CONTAINER::iterator iterEnd = container.end();
	for (iter = container.begin() ; iter != iterEnd ; ++iter)
	{	
		iter->StartRequestedRayCasts(this);	
	}
}
コード例 #14
0
ファイル: HazardModule.cpp プロジェクト: aronarts/FireNET
void HazardModule::RenderDebugProcessContainer(
	const CONTAINER& container, IPersistantDebug& debugRenderer) const
{
	typename CONTAINER::const_iterator iter;
	typename CONTAINER::const_iterator Enditer = container.end();
	for (iter = container.begin() ; iter != Enditer ; ++iter)
	{
		iter->DebugRender(debugRenderer);
	}
}
コード例 #15
0
ファイル: utilities.hpp プロジェクト: cwbaker/sweet_persist
void
clear_map_pointers( CONTAINER& container )
{
    typename CONTAINER::iterator i = container.begin();
    while ( i != container.end() )
    {
        delete i->second;
        ++i;
    }

    container.clear();
}
コード例 #16
0
ファイル: HazardModule.cpp プロジェクト: aronarts/FireNET
void HazardModule::ExpireHazardProcessContainer(
	CONTAINER& container, const HazardID hazardInstanceID)
{
	CRY_ASSERT_MESSAGE((m_UpdateLockCount == 0), "Not allowed to unregister hazards to the hazard module while it is updating!");

	int index = IndexOfInstanceID(container, hazardInstanceID);
	if (index < 0)
	{
		return;
	}

	ExpireAndDeleteHazardInstance(container, container.begin() + index);
}
コード例 #17
0
void fillContainer(T min, T max, CONTAINER& randContainer, ::boost::uint32_t seedVal = std::time(NULL))
{
    SLM_ASSERT("Wrong min/max value", min <= max);
    SLM_ASSERT("Container type not same as T", (::boost::is_same< T, typename CONTAINER::value_type>::value) );
    typedef typename ::boost::mpl::if_<
            ::boost::is_floating_point<T>,
            ::boost::uniform_real<>,
            ::boost::uniform_int<>
    >::type DistroType;

    ::boost::mt19937 seed(seedVal);
    DistroType dist(min, max);
    ::boost::variate_generator< ::boost::mt19937&, DistroType > random(seed, dist);
    std::generate(randContainer.begin(), randContainer.end(), random);
}
コード例 #18
0
ファイル: HazardModule.cpp プロジェクト: aronarts/FireNET
void HazardModule::PurgeHazardsWithPendingRayRequestsProcessContainer(CONTAINER& container)
{
	typename CONTAINER::iterator iter = container.begin();
	while (iter != container.end())
	{		
		if (iter->HasPendingRayCasts())
		{
			iter = ExpireAndDeleteHazardInstance(container, iter);
		}
		else
		{
			++iter;
		}
	}
}
コード例 #19
0
ファイル: Caching_Utility_T.cpp プロジェクト: 1ATOM/mangos
template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
ACE_Refcounted_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (CONTAINER &container,
                                                                                                         KEY *&key_to_remove,
                                                                                                         VALUE *&value_to_remove)
{
  // Starting values.
  ITERATOR end = container.end ();
  ITERATOR iter = container.begin ();
  ATTRIBUTES min = (*iter).int_id_.second ();
  key_to_remove = 0;
  value_to_remove = 0;
  // Found the minimum entry to be purged?
  int found = 0;

  // The iterator moves thru the container searching for the entry
  // with the lowest ATTRIBUTES.
  for (;
       iter != end;
       ++iter)
    {
      // If the <min> entry isnt IDLE_AND_PURGABLE continue until you reach
      // the first entry which can be purged. This is the minimum with
      // which you will compare the rest of the purgable entries.
      if ((*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
          (*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE)
        {
          if (found == 0)
            {
              min = (*iter).int_id_.second ();
              key_to_remove = &(*iter).ext_id_;
              value_to_remove = &(*iter).int_id_;
              found = 1;
            }
          else
            {
              // Ah! an entry with lower ATTTRIBUTES...
              if (min > (*iter).int_id_.second ())
                {
                  min = (*iter).int_id_.second ();
                  key_to_remove = &(*iter).ext_id_;
                  value_to_remove = &(*iter).int_id_;
                }
            }
        }
    }
}
コード例 #20
0
ファイル: wire.hpp プロジェクト: r-lyeh/wire
 strings( const CONTAINER &other ) : std::deque< string >( other.begin(), other.end() )
 {}
コード例 #21
0
ファイル: Algorithm.hpp プロジェクト: adam-erickson/PDAL
bool contains(const CONTAINER& cont, const VALUE& val)
{
    return std::find(cont.begin(), cont.end(), val) != cont.end();
}
コード例 #22
0
ファイル: utilities.hpp プロジェクト: cwbaker/sweet_persist
 bool operator()( const CONTAINER& lhs, const CONTAINER& rhs )
 {
     std::lexicographical_compare( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), PREDICATE );
 }