Example #1
0
void make_page(NDX* n, unsigned char num1,
 unsigned char num2, unsigned char top) {
  pages[top].page_index=++n->total_pages;
  pages[top].key_num=2;
  pages[top].keys=(NDX_NODE**)malloc(2*sizeof(NDX_NODE*));
  pages[top].keys[0]=get_last(n,num1);
  pages[top].keys[1]=get_last(n,num2);
}
Example #2
0
		virtual update_result update(intptr_t tid, const T* val) {
			update_result child_result = children_[child_idx(tid)]->update(child_tid(tid), val);
			intptr_t other_version = children_[1-child_idx(tid)]->get_version();

			bool tt = false;
			do {
				intptr_t my_version = get_version();
				value my_value;
				if (!history_.get(my_version, &my_value))
					break;
				if (my_value.child_versions[child_idx(tid)] >= child_result.version && my_value.child_versions[1-child_idx(tid)] >= other_version)
					break;
				value new_value;
				new_value.child_versions[0] = children_[0]->get(&new_value.child_values[0]);
				new_value.child_versions[1] = children_[1]->get(&new_value.child_values[1]);
				if (new_value.child_versions[0] == INVALID_VERSION || new_value.child_versions[1] == INVALID_VERSION)
					break;
				update_last(my_version % thread_count_);
				if (history_.publish(tid, my_version+1, &new_value)) {
					counter::inc_counter(counter::Parsum_OwnPublish, 1);
					break;
				}
			} while (true);

			counter::inc_counter(counter::Parsum_Update, 1);

			update_result result;
			bool ok = get_last(tid, &result);
			assert(ok);
			assert(result.update_count == child_result.update_count);
			return result;
		}
Example #3
0
struct bstree_node *bstree_prev(const struct bstree_node *node)
{
	struct bstree_node *left = get_left(node);
	if (left)
		return get_last(left);
	return get_prev(node);
}
Example #4
0
  void 
    advertdirectory_cpi_impl::sync_list_attributes (std::vector <std::string> & ret)
  {
      instance_data data (this);
      saga::url advert_url;
      advert_url = data->location_.clone();
      saga::url url_path         = advert_url.get_path();
      std::string last           = get_last(advert_url);
      std::string pidstring      = get_parent_id_of_entry(*client_, advert_url);
      std::string node_id_string = get_node_id(*client_, last, pidstring);

      std::vector<std::string> columnNames;
      columnNames.push_back("metakey:");
      int scanner = client_->scannerOpen("metadata", "", columnNames);
      try {
         while(true) {
            TRowResult value;
            client_->scannerGet(value, scanner);
            if(value.row == last + "-" + node_id_string) {
               std::map<std::string,TCell>::const_iterator it;
               for(it = value.columns.begin(); it != value.columns.end(); it++) {
                  ret.push_back(it->first.substr(strlen("metakey:")));
               }
            }
         }
      }
      catch(NotFound &nf) {
         client_->scannerClose(scanner);
      }
      //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
  }
Example #5
0
void update_heads(SymbolTableEntry *entry,int isFunc,int formals){//isFunc:Epipleon plhroforia sta heads twn scopelinks pou deixnoun an h allagh scopepragmatopoiithike me eisodo se synarthsh h oxi.
	int func;
	if(isFunc>0){
		func=USERFUNC;
	}
	else{
		func=0;
	}
	if(scope_heads==NULL){
		scope_heads=(SymbolTableEntry *)malloc(sizeof(SymbolTableEntry));
		scope_heads->scope_link=entry;
		scope_heads->scope=current_scope;
	}
	else{
		SymbolTableEntry *temp;
		temp=get_last(scope_heads);
		SymbolTableEntry * new_one;
		new_one=(SymbolTableEntry *)malloc(sizeof(SymbolTableEntry ));
		temp->next=new_one;
		if(formals==0){
			new_one->scope=get_current_scope();
		}
		else{
			new_one->scope=get_current_scope()+1;
		}
		new_one->scope_link=entry;
		new_one->type=func;
	}
}
Example #6
0
struct FwAvlNode* fwAvlLast(const struct FwAvlTree* tree)
{
    if((tree != 0) && (tree->root != 0))
        return get_last(tree->root);
    else
        return NULL;
}
Example #7
0
 void 
   advertdirectory_cpi_impl::sync_set_attribute (saga::impl::void_t & ret, 
                                                 std::string    key, 
                                                 std::string    val)
 {
     instance_data data (this);
     saga::url advert_url;
     advert_url = data->location_.clone();
     saga::url url_path         = advert_url.get_path();
     std::string last           = get_last(advert_url);
     std::string pidstring      = get_parent_id_of_entry(*client_, advert_url);
     std::string node_id_string = get_node_id(*client_, last, pidstring);
     std::vector<Mutation> mutations;
     mutations.push_back(Mutation());
     mutations.back().column = "metakey:" + key;
     mutations.back().value = val;
     client_->mutateRow("metadata", last + "-" + node_id_string, mutations);
     //client_->put("metadata", last + "-" + node_id_string, "metakey:" + key, val);
     mutations.clear();
     mutations.push_back(Mutation());
     mutations.back().column = "entry:node_id";
     mutations.back().value = node_id_string;
     client_->mutateRow("metadata", last + "-" + node_id_string, mutations);
     //client_->put("metadata", last + "-" + node_id_string, "entry:node_id" , node_id_string);
     //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Example #8
0
/**
 * @brief This is the public way to access HLIndex instances.
 *
 * This function first searches for an existing HIndex with the same type.
 * If an existing index is not found, it will try to open and parse a
 * highlighting file with the type name followed by `.hl`.
 *
 * If the highlighting file has been found, this function will return the
 * HLIndex of the file.  Otherwise, nullptr will be returned.
 *
 * Internally, the first request for a highlighting file will always
 * create a HLIndex branch, but for unavailable extensions, it will
 * be empty.  This will prevent FencedFilter from repeated attempts to
 * find a missing file.  When HLIndex finds an empty index, it will
 * return nullptr to revert to default doxygen processing.
 *
 * @param type Typical extension of the file type
 * @return A pointer to an HLIndex if found, nullptr otherwise.
 */
const HLIndex* HLIndex::get_index(const char *type)
{
   const HLIndex *rval = seek_index(type);
   if (!rval)
   {
      // Make an HLNode and attempt to populate it
      // with the contents of a highlight file:
      HLNode *root = new HLNode(type);
      FILE *f = find_and_open_file(type);
      if (f)
      {
         HLParser hlp(f, root);
         // Regardless of highlight file success, add a new
         // HLIndex to the chain with the new HLNode:
         HLIndex *last = get_last();
         rval = last->m_next = new HLIndex(root,
                                           hlp.hyphenated_tags(),
                                           hlp.case_insensitive());
      }
   }

   if (rval && !rval->is_empty())
      return rval;
   else
      return nullptr;
}
Example #9
0
DWORD __stdcall proc_petry( void *ptr )
{
    int pdata = (int) ptr;
    int i = 1;
     //

    while( i > 0)
    {
        if(!i) return 0;
        // Забрать фишку
        move_petry( 1 );

        i = get_last();
        //std::cout << " finished count is:" << i;

        // Отдать фишку
        move_petry( 0 );

        if (i >= 0) {
            Obrabotat( &data[i]  );
            // Отдать фишку дальше
            move_petry( 2 );
        }
    }

    return 0;
}
Example #10
0
		virtual update_result update(intptr_t tid, const T* input) {
			assert(tid == 0);
			update_result result;
			intptr_t version = history_.get_version() + 1;
			bool ok = history_.publish(0, version, input);
			assert(ok);
			ok = get_last(0, &result);
			assert(ok);
			return result;
		}
Example #11
0
struct avltree_node *avltree_prev(const struct avltree_node *node) {
    struct avltree_node *parent;

    if (node->left)
        return get_last(node->left);

    while ((parent = get_parent(node)) && parent->left == node)
        node = parent;
    return parent;
}
Example #12
0
static void			order_a(t_push **lista, t_push **listb, t_action **actions)
{
	while (!checkorder(*lista))
	{
		if (get_last(*lista) > get_before_last(*lista))
			swap_a(lista, listb, actions);
		else
			push_b(lista, listb, actions);
		order_b(lista, listb, actions);
	}
}
Example #13
0
/* 上一节点 */
static rbtree_node_st *rb_prev(const rbtree_node_st *node)
{
    rbtree_node_st *parent;

    if (node->left)
        return get_last(node->left);

    while ((parent = get_parent(node)) && parent->left == node)
        node = parent;

    return parent;
}
Example #14
0
int main()
{
	struct node n3 = { 3, NULL };
	struct node n2 = { 2, &n3 };
	struct node n1 = { 1, &n2 };

	printf("test case 1...");
	if (get_last(&n1) != &n3)
		goto fail;
	printf("[ok]\n");

	printf("test case 2 (only one node in list)...");
	if (get_last(&n3) != &n3)
		goto fail;
	printf("[ok]\n");

	return 0;
fail:
	printf("[failed]\n");
	return -1;
}
Example #15
0
void	fill_a(t_algo *algo, t_info *info)
{
	t_list	*last_a;

	last_a = get_last(algo->stack_a);
	while (algo->stack_b && (algo->op_count < info->in_count))
	{
		if ((algo->stack_b->next
			&& *(int*)algo->stack_b->data < *(int*)algo->stack_b->next->data)
			&& (algo->stack_a->next
			&& *(int*)algo->stack_a->data > *(int*)algo->stack_a->next->data))
			ss(algo);
		if (algo->stack_b->next
			&& *(int*)algo->stack_b->data < *(int*)algo->stack_b->next->data)
			sb(algo);
		if (algo->stack_a->next
			&& *(int*)algo->stack_a->data > *(int*)algo->stack_a->next->data)
			sa(algo);
		pa(algo);
		last_a = get_last(algo->stack_a);
	}
}
Example #16
0
static void			order_b(t_push **lista, t_push **listb, t_action **actions)
{
	while (checklen(*listb) > 1 && !checkorder(*listb))
	{
		if (get_last(*listb) < get_before_last(*listb))
		{
			swap_b(lista, listb, actions);
			push_a(lista, listb, actions);
		}
		else
			break ;
	}
}
Example #17
0
void n_addrec (NDX *n, char *r, unsigned long index_num) {
  unsigned char i, num;
  char *rs;
  int cmp, top;
  unsigned long page_index;
  bool changed[64], header_changed;
  NDX_NODE* key;
  key=(NDX_NODE*)malloc(8+n->key_length);
  rs=(char*)malloc(n->key_length);
  strscpy(rs,r,n->key_length);
  memset(changed,0,sizeof(changed));
  header_changed=false;

  page_index=n->root_page; top=-1;
  while (page_index) {
    get_page(n,page_index,++top);
    if (pages[top].keys[0]->index) break;
    for (i=0;i<pages[top].key_num;i++) {
      cmp=memcmp(rs,pages[top].keys[i]->key_data,n->key_length);
      if ((cmp<0) || (cmp==0 && index_num<pages[top].keys[i]->index))
       { page_index=pages[top].keys[i]->left_page; break; }
    }
    if (i==pages[top].key_num) {
      memcpy(pages[top].keys[--i],rs,n->key_length);
      changed[i]=true;
      page_index=pages[top].keys[--i]->left_page;
    }
  }
  key=make_node(n,0,index_num,rs);
  addrec(n,num=top,key);
  changed[top]=true;
  while (pages[num].key_num>n->max_keys && num>1) {
    spilt_page(n,num,++top);
    header_changed=true;
    addrec(n,num-1,get_last(n,num));
    changed[num]=changed[top]=true;
  }
  if (pages[num].key_num>n->max_keys) {
    spilt_page(n,num,++top);
    header_changed=true;
    changed[num]=changed[top]=true;
    make_page(n,num,top,top+1); top++;
    changed[top]=true;
  }
  for (i=0;i<=top;i++) {
    if (changed[i]) put_page(n,i);
    dispose_page(i);
  }
  if (header_changed) write_total(n);
}
Example #18
0
/**
 * Get previous item in the tree, following natural order.
 */
rbnode_t *
erbtree_prev(const rbnode_t *node)
{
	rbnode_t *parent;

	g_assert(node != NULL);

	if (node->left != NULL)
		return get_last(node->left);

	while (NULL != (parent = get_parent(node)) && parent->left == node)
		node = parent;
	return parent;
}
Example #19
0
  ////////////////////////////////////////////////////////////////////////
  //  namespace_dir functions
  ////////////////////////////////////////////////////////////////////////
  void 
    advertdirectory_cpi_impl::sync_list (std::vector <saga::url> & ret, 
                                         std::string               pattern, 
                                         int                       flags)
  {
      instance_data data (this);
      saga::url advert_url;
      advert_url = data->location_.clone();
      saga::url url_path         = advert_url.get_path();
      std::string last           = get_last(url_path);
      std::string pidstring      = get_parent_id_of_entry(*client_, url_path);
      std::string node_id        = get_node_id(*client_, last, pidstring);
      std::string::size_type pos = url_path.get_string().find_last_of("/");
      std::string url_minus_end  = url_path.get_string().substr(pos);
      std::string node_name;

      bool flag = false;
      std::vector<std::string> columnNames;
      columnNames.push_back("entry:");
      int scanner = client_->scannerOpen("nodes", "", columnNames);
      try {
         while(true) {
            TRowResult value;
            client_->scannerGet(value, scanner);
               std::map<std::string,TCell>::const_iterator it;
               for(it = value.columns.begin(); it != value.columns.end(); it++) {
                  if(it->first == "entry:parent_id" && it->second.value == node_id) {
                     flag = true;
                  }
                  else if(it->first == "entry:node_name") {
                     node_name = url_minus_end + it->second.value;
                     //ret.push_back();
                  }
               }
               if(flag) {
                  saga::url temp(url_path.get_string() + node_name);
                  temp.set_host(advert_url.get_host());
                  temp.set_port(advert_url.get_port());
                  temp.set_scheme(advert_url.get_scheme());
                  ret.push_back(temp);
               }
               flag = false;
         }
      }
      catch(NotFound &nf) {
         client_->scannerClose(scanner);
      }
      //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
  }
Example #20
0
  void 
    advertdirectory_cpi_impl::sync_remove_attribute (saga::impl::void_t & ret, 
                                                     std::string    key)
  {
      instance_data data (this);
      saga::url advert_url;
      advert_url = data->location_.clone();
      saga::url url_path         = advert_url.get_path();
      std::string last           = get_last(advert_url);
      std::string pidstring      = get_parent_id_of_entry(*client_, advert_url);
      std::string node_id_string = get_node_id(*client_, last, pidstring);

      client_->deleteAll("metadata", last + "-" + node_id_string, "metakey:" + key);
      //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
  }
static inline avl_node_t *
avl_tree_prev (avl_node_t *node)
{
    avl_node_t *parent;

    if (node->left)
        return 
            get_last(node->left);

    while ((parent = node->parent) && 
        (parent->left == node))
            node = parent;
        
    return parent;
}
Example #22
0
void	putprompt(void)
{
	char	*info;
	char	*pwd;
	char	*tmp;
	char	host[1024];

	ft_bzero(host, 1024);
	info = ft_getenv("USER");
	ft_printf("\x1B[32m%s\033[0m:\x1B[34m", info);
	gethostname(host, 1023);
	pwd = ft_getenv("PWD");
	info = get_last(pwd);
	tmp = get_host(host);
	ft_printf("%s\x1B[31m @ \x1B[33m%s\033[0m ~> ", tmp, info);
	ft_strdel(&info);
	ft_strdel(&tmp);
}
Example #23
0
void auto_select_event() {
  static time_t now;
  time(&now);
  get_upcoming_events(&selected_event,1,&now);
  if(!selected_event) {
    selected_event=get_last();
  }
  APP_LOG(APP_LOG_LEVEL_INFO, "auto selected event %s. location=%d %s"
	,selected_event?selected_event->description:"NULL",
 	selected_location_id,get_location(selected_location_id));
  
  scroll_up(); 
  scroll_down();
  APP_LOG(APP_LOG_LEVEL_INFO, "scrolled up to event %s",selected_event?selected_event->description:"NULL");
  //selected_event = get_nearest_event_at(selected_location_id,&now);
  //APP_LOG(APP_LOG_LEVEL_INFO, "auto selected event %s",selected_event?selected_event->description:"NULL");
  //show_event();
}
Example #24
0
struct splaytree_node *splaytree_insert(struct splaytree_node *node,
                                        struct splaytree *tree)
{
    struct splaytree_node *root = tree->root;
    int res;

    if (!root) {
        INIT_NODE(node);
        tree->root = node;
        tree->first = node;
        tree->last = node;
        return NULL;
    }

    res = do_splay(node, tree);
    if (res == 0)
        return tree->root;

    root = tree->root;
    if (res < 0) {
        struct splaytree_node *left = get_left(root);

        set_left(left, node);
        set_right(root, node);
        if (left)
            set_next(node, get_last(left));
        else
            tree->first = node;
        set_prev(node, root);
    } else {
        struct splaytree_node *right = get_right(root);

        set_right(right, node);
        set_left(root, node);
        if (right)
            set_prev(node, get_first(right));
        else
            tree->last = node;
        set_next(node, root);
    }
    tree->root = node;
    return NULL;
}
Example #25
0
        // Get data element starting from 0 as the most recent
        const T* get(int i) {
            if (size == 0)
                return nullptr; // no data yet
            else if (i >= size)
                return get_first(); // get least recent data
            else if (i <= 0)
                return get_last(); // get most recent data
            else {
                int abs_index = index - 1 - i;
                if (abs_index < 0) { // wrap to the end
                    abs_index = N + abs_index;

                    if (abs_index >= size)
                        return get_first();
                }

                return data[abs_index];
            }            
        }
Example #26
0
void	up_focus(t_list *list)
{
  t_list	*prev;

  prev = NULL;
  while (list)
  {
    if (list->focus == 1)
    {
      if (prev)
        prev->focus = 1;
      else if ((prev = get_last(list)) != NULL)
        prev->focus = 1;
      list->focus = 0;
      return;
    }
    prev = list;
    list = list->next;
  }
}
Example #27
0
File: tp3.c Project: ayoube01/C-
double int_montecarlo_save(double(*f)(double),double a, double b,int n)
{    int i;
    double res=0.0;

    int c;
    FILE *fichier=NULL;
    fichier = fopen("resultat.txt", "a");
    res=get_last("resultat.txt");
    for ( i=compteur("resultat.txt");i<n;i++)

    {

        res+=f(a+rand()*1.0/RAND_MAX*(b-a));
         fprintf(fichier,"%f",res);
         fputc(' ',fichier);
    }


return res/n;
}
Example #28
0
static void	sort_hint_2(t_hint *hint, int *i)
{
	int	var;
	int	first;
	int	last;

	first = get_first(hint->lst_data);
	last = get_last(hint->lst_data);
	var = ((t_pile*)(((t_list*)(*(hint->lst_a)))->content))->val;
	if (var < first)
	{
		p_local(hint->lst_a, hint->lst_b, hint->mark);
		r_local(hint->lst_b, hint->mark);
		(*i)++;
	}
	else if (var >= last)
	{
		p_local(hint->lst_a, hint->lst_b, hint->mark);
		(*i)++;
	}
}
Example #29
0
  void 
    advertdirectory_cpi_impl::sync_is_dir (bool      & ret, 
                                           saga::url   entry)
  {
      instance_data data (this);
      saga::url advert_url;
      advert_url = data->location_.clone();
      saga::url url_path         = advert_url.get_path();
      std::string string_arg     = get_full_url(advert_url, entry);
      saga::url arg(string_arg);
      std::string last           = get_last(arg);
      std::string pidstring      = get_parent_id_of_entry(*client_, arg);
      std::string node_id_string = get_node_id(*client_, last, pidstring);

      std::vector<std::string> columnNames;
      columnNames.push_back("entry:");
      int scanner = client_->scannerOpen("nodes", "", columnNames);
      try {
         while(true) {
            TRowResult value;
            client_->scannerGet(value, scanner);
            if(value.row == last + "-" + node_id_string) {
               std::map<std::string,TCell>::const_iterator it;
               for(it = value.columns.begin(); it != value.columns.end(); it++) {
                  if(it->first == "entry:is_dir") {
                     if(it->second.value == "false") 
                        ret = false;
                     else
                        ret = true;
                  }
               }
            }
         }
      }
      catch(NotFound &nf) {
         client_->scannerClose(scanner);
      }
      //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
  }
Example #30
0
int main () {
    int array[6] = {0, 1, 2, 3, 4, 5};

    list_node* first = list_init(array, 6, 7);
    list_node *fourth, *fifth; //We'll iterate through the list and get these
    
    //Iterate through the list
    for (list_node *current = first, *previous = 0;
         current != 0;
         advance(&previous, &current)) {
        //Print off the current item
        printf("%d  ", current->item);

        if (current->item == true) {
            fourth = previous;
            fifth = current;
        }
    }

	*printf;
	
	int for;
    
    *fifth = *fourth;
	
    puts((list_node) "\nInserting 6, deleting 3");
    list_node* newnode = insert_between(fourth, fifth, 6);
    node_delete(newnode, fourth);

    //Print them off again, backwards!
    for (list_node *current = get_last(first), *previous = 0;
         current != 0;
         advance(&previous, &current))
        printf("%d  ", current->item);

    puts("", 2);
	
    return 0;
}