예제 #1
0
파일: humandesign.cpp 프로젝트: ny-c/ce
		void add_connected_gates(int gate, std::forward_list<int>& gates)
		{
			for(size_t i = 0; i < channels.size(); ++i) {

				if(channels[i][0] == gate)
					gates.push_front(channels[i][1]);

				if(channels[i][1] == gate)
					gates.push_front(channels[i][0]);
			}
		}
예제 #2
0
void AreaCombat::getList(const Position& centerPos, const Position& targetPos, std::forward_list<Tile*>& list) const
{
	const MatrixArea* area = getArea(centerPos, targetPos);
	if (!area) {
		return;
	}

	uint32_t centerY, centerX;
	area->getCenter(centerY, centerX);

	Position tmpPos(targetPos.x - centerX, targetPos.y - centerY, targetPos.z);
	uint32_t cols = area->getCols();
	for (uint32_t y = 0, rows = area->getRows(); y < rows; ++y) {
		for (uint32_t x = 0; x < cols; ++x) {
			if (area->getValue(y, x) != 0) {
				if (g_game.isSightClear(targetPos, tmpPos, true)) {
					Tile* tile = g_game.map.getTile(tmpPos);
					if (!tile) {
						tile = new StaticTile(tmpPos.x, tmpPos.y, tmpPos.z);
						g_game.map.setTile(tmpPos, tile);
					}
					list.push_front(tile);
				}
			}
			tmpPos.x++;
		}
		tmpPos.x -= cols;
		tmpPos.y++;
	}
}
예제 #3
0
    static void extract(const jsonpack::value &v, char* json_ptr, std::forward_list<T> &value)
    {
        array_t arr = *v._arr;

        value.clear();

        for(const auto &it : arr)
        {
#ifndef _MSC_VER
            // Initialize before use
            T val = {};
#else
            T val;
#endif  
            if( json_traits<T&>::match_token_type(it) )
            {
                json_traits<T&>::extract(it, json_ptr, val);
                // forward_list not support insert operation
                value.push_front(val);
            }
            else
            {
                throw type_error( "Forward_list item type mismatch" );
            }

        }
    }
예제 #4
0
typename boost::disable_if<
    typename detail::is_default_constructible<
        typename std::forward_list<T, Allocator>::value_type
    >,
    void
>::type
collection_load_impl(
    Archive & ar,
    std::forward_list<T, Allocator> &t,
    collection_size_type count,
    item_version_type item_version
){
    t.clear();
    boost::serialization::detail::stack_construct<Archive, T> u(ar, item_version);
    ar >> boost::serialization::make_nvp("item", u.reference());
    t.push_front(u.reference());
    typename std::forward_list<T, Allocator>::iterator last;
    last = t.begin();
    ar.reset_object_address(&(*t.begin()) , & u.reference());
    while(--count > 0){
        detail::stack_construct<Archive, T> u(ar, item_version);
        ar >> boost::serialization::make_nvp("item", u.reference());
        last = t.insert_after(last, u.reference());
        ar.reset_object_address(&(*last) , & u.reference());
    }
}
예제 #5
0
 StackTrieNode *createTrieNode(uint32_t ThreadId, int32_t FuncId,
                               StackTrieNode *Parent) {
   NodeStore.push_front(StackTrieNode{FuncId, Parent, {}, {{}, {}}});
   auto I = NodeStore.begin();
   auto *Node = &*I;
   if (!Parent)
     Roots[ThreadId].push_back(Node);
   return Node;
 }
예제 #6
0
void add(string term){
	if(terms.find(term) == terms.end()){
		node *n = new node;
		n->t=term;
		n->i=1;
		termStack.push_front(*n);
		terms[term]=&termStack.front();			
	}
	else{
		terms[term]->i++;
	}
}
예제 #7
0
void rReverse(std::forward_list<int> &l){
	
	if(!l.empty()){
		 a = l.front();

		l.pop_front();  //Remove all elements until empty

		rReverse(l); 
	}else{

		l.push_front(a); //Insert elements from the function stack
		
	}
	
}
예제 #8
0
// TraialPool::get_traials() specialization for STL std::forward_list<>
template<> void
TraialPool::get_traials(std::forward_list< Reference<Traial> >& flist,
						unsigned numTraials)
{
	assert(0u < numTraials);
	numTraials++;  // loop guard condition requires this increment
	retrieve_traials:
	while (!available_traials_.empty() && 0u < --numTraials) {
		flist.push_front(available_traials_.front());
		available_traials_.pop_front();
	}
	if (0u < numTraials) {
		ensure_resources(std::max<unsigned>(numTraials++, sizeChunkIncrement));
		goto retrieve_traials;
	}
}
예제 #9
0
void Combat::getCombatArea(const Position& centerPos, const Position& targetPos, const AreaCombat* area, std::forward_list<Tile*>& list)
{
	if (targetPos.z >= MAP_MAX_LAYERS) {
		return;
	}

	if (area) {
		area->getList(centerPos, targetPos, list);
	} else {
		Tile* tile = g_game.map.getTile(targetPos);
		if (!tile) {
			tile = new StaticTile(targetPos.x, targetPos.y, targetPos.z);
			g_game.map.setTile(targetPos, tile);
		}
		list.push_front(tile);
	}
}
예제 #10
0
// TraialPool::get_traial_copies() specialization for STL std::forward_list<>
template<> void
TraialPool::get_traial_copies(std::forward_list< Reference<Traial> >& flist,
                              const Traial& traial,
							  unsigned numCopies,
							  short depth)
{
	assert(0u < numCopies);
	assert(0 >= depth);  // we're typically called on a threshold-level-up
	numCopies++;  // loop guard condition requires this increment
	retrieve_traials:
	while (!available_traials_.empty() && 0u < --numCopies) {
		Traial& t = available_traials_.front();
        available_traials_.pop_front();
        t = traial;
		t.depth = depth;
		flist.push_front(std::ref(t));  // copy elision
    }
	if (0u < numCopies) {
		ensure_resources(std::max<unsigned>(numCopies++, sizeChunkIncrement));
		goto retrieve_traials;
	}
}
예제 #11
0
파일: Nnode.cpp 프로젝트: rand0wn/ask-dsa
//Using recursion
int rReturn(std::forward_list<int> l, int n){

    static int i = 0;

	if(i == n)
 	return l.front();

	if(!l.empty())
		
	{
	int a = l.front();
	
	l.pop_front();

	rReturn(l, n);
	
	l.push_front(a);

	i++;
	
     }
	
}
예제 #12
0
파일: SubForm.hpp 프로젝트: DRIZO/xcsoar
 /**
  * Add a #Window to the "destruct" list: the object will be deleted
  * by calling the class's Clear() method.  This means that the caller
  * doesn't have to keep track of the specified Window, because this
  * SubForm is now responsible for freeing memory.
  * Clear() must be called before deleting this form to delete windows
  * in the list.
  */
 void AddDestruct(Window *window) {
   destruct_windows.push_front(window);
 }
예제 #13
0
파일: Board.cpp 프로젝트: den4ix/8puzzle
void Board::boardToList(int ri, int ci, int rn, int cn, std::forward_list<Board*> & l)
{
	Board*b = new Board(this);
        exch(b->blocks, ri, ci, rn, cn);
	l.push_front(b);
}
예제 #14
0
파일: signal.hpp 프로젝트: ftk/niceamx
 inline void connect(const slot_t& f) // O(1)
 {
   slots.push_front(f);
 }
예제 #15
0
static void
fbsd_add_vfork_done (ptid_t pid)
{
  fbsd_pending_vfork_done.push_front (pid);
}
void good_push_front_forward_list1(std::forward_list<int> &FL, int n) {
  auto i0 = FL.cbegin(), i1 = FL.cend();
  FL.push_front(n);
  *i0; // no-warning
}
예제 #17
0
 void push(int x) {
     data_.push_front(x);
     mins_.push_front(mins_._empty() ? x : std::min(x, mins_.front()));
 }