Example #1
0
ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_List_T (FUNCTOR* uf,
                    FreeList* fl,
                    TIME_POLICY const & time_policy)
  : Base_Timer_Queue (uf, fl, time_policy)
  , head_ (new ACE_Timer_Node_T<TYPE>)
  , id_counter_ (0)
{
  ACE_TRACE ("ACE_Timer_List_T::ACE_Timer_List_T");

  this->head_->set_next (this->head_);
  this->head_->set_prev (this->head_);

  ACE_NEW (iterator_, Iterator(*this));
}
Example #2
0
	//non constant version of find
  Iterator Find(const T& value)
  {
    uint32_t hidx=getIndex(&value);
    Node** nodePtr=&hash[hidx];
    if(!*nodePtr)return Iterator(0);
    if(TRAITS::isEqual((*nodePtr),&value))
    {
      return Iterator(this,hidx,*nodePtr,nodePtr);
    }
    Node** parentPtr=nodePtr;
    Node* node=(Node*)(*nodePtr)->ihsNextNode;
    while(node)
    {
      if(TRAITS::isEqual(node,&value))
      {
        return Iterator(this,hidx,node,parentPtr);
      }
      parentPtr=nodePtr;
      nodePtr=(Node**)&node->ihsNextNode;
      node=(Node*)node->ihsNextNode;
    }
    return Iterator(0);
  }
Example #3
0
  filter_iterator<Predicate,Iterator>
  make_filter_iterator(
      typename iterators::enable_if<
          is_class<Predicate>
        , Iterator
      >::type x
    , Iterator end = Iterator()
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
    , Predicate* = 0
#endif 
  )
  {
      return filter_iterator<Predicate,Iterator>(x,end);
  }
Example #4
0
// Updates the timed callback functions
void _Scripting::UpdateTimedCallbacks() {

	for(std::list<TimedCallbackStruct>::iterator Iterator(TimedCallbacks.begin()); Iterator != TimedCallbacks.end(); ++Iterator) {
		if(PlayState.GetTimer() >= (*Iterator).TimeStamp) {
			Scripting.CallFunction((*Iterator).Function);

			// Remove callback
			Iterator = TimedCallbacks.erase(Iterator);
			if(Iterator == TimedCallbacks.end())
				break;
		}
		else
			return;
	}
}
Example #5
0
XmlReader::XmlReader(std::string const& filepath) :
    token_(token_none), is_empty_element(false)
  {
  std::ifstream stream(filepath, std::ios::binary);
  if (!stream)
    {
    throw std::runtime_error("cannot open file " + filepath);
    }
  stream.unsetf(std::ios::skipws);
  stream.seekg(0, std::ios::end);
  std::size_t size = static_cast<std::size_t>(stream.tellg());
  stream.seekg(0);
  buffer.resize(size + 1);
  cursor = marker = Iterator(buffer.begin());
  stream.read(&buffer[0], static_cast<std::streamsize>(size));
  buffer[size] = 0;
  }
void test() {
	NodePtr hello = new Leaf("hello");
	NodePtr world = new Leaf("world");
	//check_node(hello);
	NodePtr hw = hello->concat_with(world);
	//hw->debug_print();
	check_node(hw);

	//concatenation
	for (int i = 0; i<100; i++) {
		if (i%20 == 0)
			std::cout<<i<<std::endl;
		hw = hw->concat_with(hello);
		//hw->debug_print();
		assert(check_node(hw));
	}
	assert(check_node(hw));
	hw->debug_print();

	//random access
	for (int i = 0; i<100; i++) {
		Iterator iter = Iterator(hw);
		int pos = 0;
		std::string s = hw->as_string();
		while (pos < hw->length()) {
			//std::cout<<pos<<" ";
			assert(s[pos] == iter.current());
			int d = rand()%100;
			pos += d;
			iter.advance(d);
		}
		assert(!iter.valid);
		//std::cout<<std::endl;
	}

	//slices
	for (int i = 0; i<100; i++) {
		int begin = rand()%(hw->length()+1);
		int end = begin+rand()%(hw->length()-begin+1);
		NodePtr slice = hw->slice(begin, end);
		assert(check_node(slice));
		std::cout<<begin<<" "<<end<<std::endl;
	}
	std::cout<<"hw depth "<<hw->depth()<<std::endl;
}
Example #7
0
namespace sfft { namespace detail
{
  template<typename T>
  std::vector<std::complex<T> > getTwiddleFactors(size_t N, bool fwd,
    size_t Lm1Qm1 = std::numeric_limits<size_t>::max)
  {
    std::vector<std::complex<T> > factors(std::min(N, Lm1Qm1));
    if(factors.size() > 0)
    {
      factors[0] = 1;
      if(factors.size() > 1)
      {
        // Use high-precision multiplication of phasors.
        typedef std::complex<long double> HighPrecComplex;
        long double phase = 2*3.14159265358979323846/N;
        HighPrecComplex phasor(cos(phase), fwd ? -sin(phase) : sin(phase));
        HighPrecComplex tmp(phasor);
        factors[1] = tmp;
        for(size_t i = 2; i < factors.size(); ++i)
          factors[i] = tmp = tmp * phasor;
      }
    }
    return factors;
  }
} // namespace detail

template<typename Iterator>
using DereferencedType = typename std::remove_reference<decltype(*(Iterator()))>::type;

template<typename T>
struct Twiddler
{
  Twiddler(size_t N_, bool fwd,
    size_t Lm1Qm1 = std::numeric_limits<size_t>::max())
    :factors(detail::getTwiddleFactors<T>(N_, fwd, Lm1Qm1)),
    N(N_) {}

  const std::vector<std::complex<T> > factors;
  const size_t N;
};

} //namespace sfft
Example #8
0
namespace maxwell {


/// \needsdoc
template<class Iterator, class Mapping>
class mapping_iterator : public Iterator {
public:
	typedef mapping_iterator self;
	typedef Iterator iterator_type;
	typedef Mapping mapping_type;
	typedef typename Mapping::result_type result_type;

	explicit mapping_iterator(Mapping m): mapping(m) {}
	explicit mapping_iterator(Iterator it): Iterator(it) {}
	mapping_iterator(Iterator it, Mapping m): Iterator(it), mapping(m) {}

	result_type operator*() const { return mapping(Iterator::operator*()); }
	result_type operator->() const { return mapping(Iterator::operator->()); }

private:
	mapping_type mapping;
};


/// \needsdoc
template<class T>
struct dereference {
	typedef T argument_type;
	typedef decltype(*T(nullptr)) result_type;

	result_type operator() (T const& x) const { return *x; }
};


/// \needsdoc
template<class Iterator>
using dereferencing_iterator = mapping_iterator<Iterator, dereference<
	typename std::remove_reference<decltype(*Iterator())>::type>
>;


} // namespace maxwell
Example #9
0
  Iterator  erase_after(const Iterator&  it)
  {
    auto  target = it.ptr->next               ;
                   it.ptr->next = target->next;

      if(last == target)
      {
        last = target->next;

          if(last == nullptr)
          {
            first = nullptr;
          }
      }


    delete target;

    return Iterator(it.ptr->next);
  }
int main(int, char* [] )
{
    typedef itk::Image<unsigned char, 2> ImageType;
    ImageType::Pointer image = ImageType::New();

    itk::Index<2> corner = {{0,0}};
    itk::Size<2> size = {{10,10}};
    itk::ImageRegion<2> region(corner,size);
    image->SetRegions(region);
    image->Allocate();

    unsigned int counter = 0; // To make sure the loop isn't optimized away
    for(unsigned int i = 0; i < 1e7; ++i)
    {
        counter += Iterator(image.GetPointer()); // about 7.2 seconds
//    counter += IteratorWithIndex(image.GetPointer()); // about 2.6 seconds
    }

    std::cout << "counter " << counter << std::endl; // To make sure the loop isn't optimized away
    return 0;
}
Example #11
0
			Iterator find(const Key_T &key) 
			{ 
				Node* current_node;
				Node* fallback_node = levels;

				for(int i = (MaxLevel - 1); i >= 0; i--)
				{
					current_node = fallback_node;
					while(current_node != NULL)
					{
						fallback_node = current_node;
						if(current_node->nodes[i] == NULL || current_node->nodes[i]->dataPair.first > key)
							break; // Next string on this node
						else if (current_node->nodes[i]->dataPair.first == key)
							return Iterator(current_node->nodes[i]);
						else if(current_node->nodes[i]->dataPair.first < key)
							current_node = current_node->nodes[i];
					}
				}
				return NULL;
			}
Example #12
0
void SceneGraph::Iterator::
find_next_node_breadth() {

    if (breadth_nodes_.empty()) {
        Iterator end;
        for (Iterator it(start_node_); it != end; ++it)
            breadth_nodes_[it.get_depth()].push_back(it.current_node_);
    }

    auto end(breadth_nodes_[current_depth_].end());
    for (auto node(breadth_nodes_[current_depth_].begin());
              node != end; ++node) {

        if (*node == current_node_) {
            if (++node != end) {
                current_node_ = *node;
            } else if (++current_depth_ < breadth_nodes_.size()) {
                current_node_ = breadth_nodes_[current_depth_].front();
            } else *this = Iterator();
            break;
        }
    }
}
Example #13
0
 Iterator begin() const { 
   return Iterator(*this); 
 }
Example #14
0
		Iterator end()
		{
			return Iterator(0);
		}
Example #15
0
		Iterator begin()
		{
			return Iterator(first);
		}
Example #16
0
File: main.cpp Project: CCJY/coliru
 Iterator end() const { return Iterator(_offset+_size); }
Example #17
0
DBCFile::Iterator DBCFile::end()
{
    assert(data);
    return Iterator(*this, stringTable);
}
Example #18
0
 Iterator end() const {
     return Iterator(
             this->container.end(),
             this->container.end(),
             this->filter_func);
 }
Example #19
0
inline filter_iterator<Predicate,Iterator>
make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator())
{
    return filter_iterator<Predicate,Iterator>(f,x,end);
}
 token_iterator(Iterator begin, Iterator e = Iterator())
     : f_(),begin_(begin),end_(e),valid_(false),tok_() {
     initialize();
 }
Example #21
0
	SequenceSelector::Iterator SequenceSelector::Begin()
	{
		return Iterator(this);
	}		
TerrainQuadTree::Iterator TerrainQuadTree::getIterator () const
{
	return Iterator (m_nodes);
}
Example #23
0
	Geometry::Iterator Geometry::tangentsCend() const
	{
		return Iterator( this, m_tangentsStride, m_vertexSize, m_indices.cend() );
	}
Example #24
0
inline Iterator connect(basic_socket<Protocol ASIO_SVC_TARG>& s,
    Iterator begin, asio::error_code& ec,
    typename enable_if<!is_endpoint_sequence<Iterator>::value>::type*)
{
  return connect(s, begin, Iterator(), detail::default_connect_condition(), ec);
}
Example #25
0
void ClientList::SendClientVersionSummary(const char *Name)
{
	uint32 Client62Count = 0;
	uint32 ClientTitaniumCount = 0;
	uint32 ClientSoFCount = 0;
	uint32 ClientSoDCount = 0;
	uint32 ClientUnderfootCount = 0;
	uint32 ClientRoFCount = 0;

	LinkedListIterator<ClientListEntry*> Iterator(clientlist);

	Iterator.Reset();

	while(Iterator.MoreElements())
	{
		ClientListEntry* CLE = Iterator.GetData();

		if(CLE && CLE->zone())
		{
			switch(CLE->GetClientVersion())
			{
				case 1:
				{
					++Client62Count;
					break;
				}
				case 2:
				{
					++ClientTitaniumCount;
					break;
				}
				case 3:
				{
					++ClientSoFCount;
					break;
				}
				case 4:
				{
					++ClientSoDCount;
					break;
				}
				case 5:
				{
					++ClientUnderfootCount;
					break;
				}
				case 6:
				{
					++ClientRoFCount;
					break;
				}
				default:
					break;
			}
		}

		Iterator.Advance();

	}

	zoneserver_list.SendEmoteMessage(Name, 0, 0, 13, "There are %i 6.2, %i Titanium, %i SoF, %i SoD, %i UF, %i RoF clients currently connected.",
					Client62Count, ClientTitaniumCount, ClientSoFCount, ClientSoDCount, ClientUnderfootCount, ClientRoFCount);
}
Example #26
0
 filter_iterator(Predicate f, Iterator x, Iterator end_ = Iterator())
     : super_t(x), m_predicate(f), m_end(end_)
 {
     satisfy_predicate();
 }
Example #27
0
DBCFile::Iterator DBCFile::begin()
{
    assert(data);
    return Iterator(*this, data);
}
Example #28
0
File: main.cpp Project: CCJY/coliru
 Iterator operator - (difference_type d) const { return Iterator(_index-d); }
Example #29
0
	const EntityView::Iterator EntityView::begin() const
	{
		return Iterator(_manager, _mask);
	}
Example #30
0
File: main.cpp Project: CCJY/coliru
 Iterator begin() const { return Iterator(_offset); }