Пример #1
0
void
sanguis::server::auras::update_sight::leave(
	sanguis::server::entities::with_body &_entity
)
{
	fcppt::optional::maybe_void(
		fcppt::cast::dynamic_cross<
			sanguis::server::entities::with_id const
		>(
			_entity
		),
		[
			this
		](
			fcppt::reference<
				sanguis::server::entities::with_id const
			> const _with_id
		)
		{
			remove_(
				_with_id.get()
			);
		}
	);
}
Пример #2
0
 void remove(const string& name){
   auto itr = networkMap_.find(name);
   if(itr == networkMap_.end()){
     return;
   }
   remove_(itr->second);
   networkMap_.erase(itr);
 }
Пример #3
0
Str& Str::operator= (int num)
{
    remove_();
    char buf[20];
    sprintf(buf,"%d",num);
    operator=(buf);
    return *this;
}
Пример #4
0
Str& Str::operator= (double num)
{
    remove_();
    char buf[20];
    sprintf(buf,"%.13g",num);
    operator=(buf);
    return *this;
}
Пример #5
0
 bool ServerCollect::remove(const common::ArrayHelper<BlockCollect*>& blocks)
 {
   RWLock::Lock lock(mutex_, WRITE_LOCKER);
   for (int32_t i = 0; i < blocks.get_array_index(); ++i)
   {
     remove_(*blocks.at(i));
   }
   return true;
 }
Пример #6
0
void Str::nset(const char* chars, int len)
{
    sabassert(chars);
    remove_();
    byteLength_ = len;
    text_ = claimMemory(len + 1);
    memcpy(text_, chars, len);
    text_[len] = 0;
}
Пример #7
0
Str& Str::operator=(const Str& string)
{
    remove_();
    int hisByteLen = string.length();
    byteLength_ = hisByteLen;
    text_ = claimMemory(hisByteLen + 1);
    memcpy(operator char*(), string.operator char*(), hisByteLen+1);
    return *this;
}
Пример #8
0
Str& Str::operator= (char c)
{
    remove_();
    char *p;
    *(p = claimMemory(2)) = c;
    p[1] = 0;
    byteLength_ = 1;
    text_ = p;
    return *this;
}
	void TwoThreeTree::remove(int key){
		if ( remove_(root, key))
			root = NULL;
		else if (root != NULL && root->child.size() == 1){
			auto t = root;
			root = root->child[0];
			t->child.clear();
			delete t;
		}
	}
Пример #10
0
DStr& DStr::appendSelf(DStr& other)
{
    other.nadd(text_, byteLength_);
    DynBlockItem *b;
    for (b = blocks.first; b; b = b -> next)
        other.nadd(b -> data, b -> byteCount);
    remove_();
    byteLength_ = 0;
    return other;
}
Пример #11
0
bool Set::remove(int value){

	for (int i = 0; i < size; i++){

		if (values[i] == value){
			return remove_(i);
		}

	}

	return 0;

}
	bool TwoThreeTree::remove_(Node *node, int key){
		if (node == NULL)
			return false;
		if (node->isLeaf()){
			if (node->key == key){
				delete node;
				return true;
			}
			return false;
		}
		int toRemove = node->findChildNo(key);
		if (remove_(node->child[toRemove], key)){
			node->child.erase(node->child.begin() + toRemove);
			return false;
		}

		if (node->child[toRemove]->child.size() == 1){
            int borrower = -1;
			if (toRemove > 0 && node->child[toRemove - 1]->child.size() == 3){
				borrower = toRemove - 1;
			}
			else {
				if (toRemove < node->child.size() - 1 && node->child[toRemove + 1]->child.size() == 3)
			borrower = toRemove + 1;
			}
		
		if (borrower != -1){
			node->child[toRemove]->child[1] = node->child[borrower]->child[2];
			node->child[borrower]->child.pop_back();
		}else{
			if (toRemove > 0)
				borrower = toRemove - 1;
			else
				borrower = toRemove + 1;
			auto tmp = *(node->child[toRemove]->child.rbegin());
			node->child[borrower]->child.push_back(tmp);
			node->child[toRemove]->child.pop_back();
			delete node->child[toRemove];
			node->child.erase(node->child.begin() + toRemove);
		}
        }
		return false;
	}
Пример #13
0
// Tokenizes the instruction part of the text command. If it corresponds to one of the supported
// instructions, like "add" or "remove", it searches for the next token (the sample name) in the
// list of samples and sends its buttonID to the relevant instruction function for further processing
void instructionControl(char *string_pointer) {
  char *buttonID = NULL;
  int instruction_to_execute;

  if (!string_pointer) {
    return;
  }

  instruction_to_execute = selectInstruction(string_pointer);

  string_pointer = strtok(NULL, " \n");

  if (string_pointer != NULL) {
    buttonID = findSampleInArray(string_pointer); //
  }

  switch(instruction_to_execute) {
    case ADD: add_(buttonID); break;
    case REMOVE: remove_(buttonID); break;
    case SET: set_(string_pointer); break;
    case STOP: stopAll_(); break;
  }
}
Пример #14
0
void Tracked_Blip_Buffer::remove_samples( long n )
{
	remove_( n );
	Blip_Buffer::remove_samples( n );
}
Пример #15
0
void Tracked_Blip_Buffer::remove_silence( long n )
{
	remove_( n );
	Blip_Buffer::remove_silence( n );
}
Пример #16
0
DStr::~DStr()
{
    remove_();
}
Пример #17
0
int IDENTIFIER(void) {
  d("IDENTIFIER",token,pending);
  if (!id("X")) return 0;
remove_("X");
  return 1;
}
Пример #18
0
DStr& DStr::operator=(const DStr& other)
{
    remove_();
    operator+=(other);
    return *this;
}
Пример #19
0
DStr& Str::appendSelf(DStr& other)
{
    other.nadd(operator char*(), length());
    remove_();
    return other;
}
Пример #20
0
Str::~Str()
{
    remove_();
}
Пример #21
0
void Str::empty()
{
    byteLength_ = 0;
    remove_();
    *(text_ = claimMemory(1)) = 0;
}
Пример #22
0
 bool ServerCollect::remove(BlockCollect* block)
 {
   RWLock::Lock lock(mutex_, WRITE_LOCKER);
   return  NULL != block ? remove_(block) : false;
 }
Пример #23
0
static void ant_rlf(gcp_solution_t *sol, gcp_t *problem) {/*{{{*/

	int i, j;
	int colornumber = 0;	/* number of colors used */
	int colored = 0;		/* number of colored vertex */
	int v, new_v;			/* vertex to be colored */
	int nn;					/* keep number of non-neighbors of v */
	double *probb;			/* probabilities for choosing a vertex */
	
/*{{{*/
	static int *degree = NULL;
	static int **adj = NULL;
	static int *ctr = NULL;
	if (!ctr) {
		degree = malloc_(sizeof(int) * problem->size);
		adj = malloc_(sizeof(int*) * problem->size);
	}

	for (i = 0; i < problem->size; i++) {
		degree[i] = problem->degree[i];

		if (!ctr) {
			adj[i] = malloc(sizeof(int) * problem->size);
		}

		for (j = 0; j < problem->size; j++) {
			adj[i][j] = problem->adj[i][j];
//			adj[j][i] = problem->adj[j][i];
		}
	}
	ctr = degree;
/*}}}*/

	while (colored < problem->size) {

		v = first_vertex(degree, problem->size);

		sol->color[v] = colornumber;
        sol->nodes_color[colornumber]++;
		colored++;

		nn = problem->size - degree[v] - 1;
		for (i = 0; i < problem->size; i++) {
			if (!adj[v][i] && (degree[i] == OUT)) {
				nn--;
			}
		}

		while (nn > 0) {
			
            /* choose new_v, non neighbor of v that is not OUT with probability p */
			/*
            probb = calculate_probbs(v, problem->size, colornumber, degree, 
							adj, sol->color, problem->alpha, problem->beta);
	        new_v = choose_vertex(probb, problem->size);
			*/
			new_v = 0;
            while (v==new_v || (degree[new_v]==OUT) || adj[new_v][v]) new_v++;
			for (i = new_v; i < problem->size; i++) {
				if ((i != v) && !adj[v][i] && (degree[i] != OUT) && (degree[i] > degree[new_v]))
					new_v = i;						
			}
			

			sol->color[new_v] = colornumber;
			sol->nodes_color[colornumber]++;
			colored++;

			contract(v, new_v, degree, adj, problem->size, &nn);

			nn--;

		}

		remove_(v, degree, adj, problem->size);
		colornumber++;

	}

	sol->spent_time = current_usertime_secs();
	sol->ncolors = colornumber;

}/*}}}*/
Пример #24
0
/**
 * qhasharr->put(): Put an object into this table.
 *
 * @param tbl       qhasharr_t container pointer.
 * @param key       key string
 * @param value     value object data
 * @param size      size of value
 *
 * @return true if successful, otherwise returns false
 * @retval errno will be set in error condition.
 *  - ENOBUFS   : Table doesn't have enough space to store the object.
 *  - EINVAL    : Invalid argument.
 *  - EFAULT    : Unexpected error. Data structure is not constant.
*/
static bool put(qhasharr_t *tbl, const char *key, const void *value,
                size_t size)
{
    if (key == NULL || value == NULL) {
        errno = EINVAL;
        return false;
    }

    // check full
    if (tbl->usedslots >= tbl->maxslots) {
        DEBUG("hasharr: put %s - FULL", key);
        errno = ENOBUFS;
        return false;
    }

    // get hash integer
    unsigned int hash = qhashmurmur3_32(key, strlen(key)) % tbl->maxslots;

    // check, is slot empty
    if (tbl->slots[hash].count == 0) { // empty slot
        // put data
        if (_put_data(tbl, hash, hash, key, value, size, 1) == false) {
            DEBUG("hasharr: FAILED put(new) %s", key);
            return false;
        }
        DEBUG("hasharr: put(new) %s (idx=%d,hash=%u,tot=%d)",
              key, hash, hash, tbl->usedslots);
    } else if (tbl->slots[hash].count > 0) { // same key or hash collision
        // check same key;
        int idx = _get_idx(tbl, key, hash);
        if (idx >= 0) { // same key
            // remove and recall
            remove_(tbl, key);
            return put(tbl, key, value, size);
        } else { // no same key, just hash collision
            // find empty slot
            int idx = _find_empty(tbl, hash);
            if (idx < 0) {
                errno = ENOBUFS;
                return false;
            }

            // put data. -1 is used for collision resolution (idx != hash);
            if (_put_data(tbl, idx, hash, key, value, size, -1) == false) {
                DEBUG("hasharr: FAILED put(col) %s", key);
                return false;
            }

            // increase counter from leading slot
            tbl->slots[hash].count++;

            DEBUG("hasharr: put(col) %s (idx=%d,hash=%u,tot=%d)",
                  key, idx, hash, tbl->usedslots);
        }
    } else {
        // in case of -1 or -2, move it. -1 used for collision resolution,
        // -2 used for oversized value data.

        // find empty slot
        int idx = _find_empty(tbl, hash + 1);
        if (idx < 0) {
            errno = ENOBUFS;
            return false;
        }

        // move dup slot to empty
        _copy_slot(tbl, idx, hash);
        _remove_slot(tbl, hash);

        // in case of -2, adjust link of mother
        if (tbl->slots[idx].count == -2) {
            tbl->slots[ tbl->slots[idx].hash ].link = idx;
            if (tbl->slots[idx].link != -1) {
                tbl->slots[ tbl->slots[idx].link ].hash = idx;
            }
        }

        // store data
        if (_put_data(tbl, hash, hash, key, value, size, 1) == false) {
            DEBUG("hasharr: FAILED put(swp) %s", key);
            return false;
        }

        DEBUG("hasharr: put(swp) %s (idx=%u,hash=%u,tot=%d)",
              key, hash, hash, tbl->usedslots);
    }

    return true;
}
Пример #25
0
template<typename T, typename... Args> void remove(T& arg, Args&&... args) { remove_(arg); remove(args...); }
Пример #26
0
long Tracked_Blip_Buffer::read_samples( blip_sample_t* out, long count )
{
	count = Blip_Buffer::read_samples( out, count );
	remove_( count );
	return count;
}
Пример #27
0
bool remove(string const& file_path, const mpi::comm& comm) {
  return mpi::root_do(comm, [&]() { return remove_(file_path, comm); });
}
Пример #28
0
Str& Str::operator=(const DStr& dynamic)
{
    remove_();
    nset((char*) dynamic, dynamic.length());
    return *this;
}
Пример #29
0
 ~NNModule_(){
   for(auto itr : networkMap_){
     remove_(itr.second);
   }
 }