void unshuffle(item_t *array,int left,int right)
{
	int i,j;
	int n=right-left+1;
	int middle=(left+right)/2;
	item_t *aux;

	if(right-left+1<=1){
		return;
	}


	aux=malloc(n*sizeof(*aux));

	for(j=0,i=left;i<=right;j++,i+=2){
		copy_item(&aux[j],&array[i]);
	}

	for(j=middle+1-left,i=left+1;i<=right;j++,i+=2){
		copy_item(&aux[j],&array[i]);
	}

	for(i=left;i<=right;i++){
		copy_item(&array[i],&aux[i-left]);
	}

	free(aux);
}
示例#2
0
void database::swap_item(TItemStData *from, TItemStData *to)
{
	TItemStData buf;
	copy_item(to, &buf);
	copy_item(from, to);
	copy_item(&buf, from);
}
static pqueue_link_t do_pqueue_construct(item_t *array,int left,int right)
{
	pqueue_link_t r;
	int middle=(left+right)/2;
	item_t max_item;

	r=malloc(sizeof(*r));
	r->left=NULL;
	r->right=NULL;

	if(right==left){
		r->item=array[left];
	
		return(r);
	}

	r->left=do_pqueue_construct(array,left,middle);
	r->right=do_pqueue_construct(array,middle+1,right);
	
	copy_item(&max_item,&r->left->item);
	if(compare_item(r->right->item,max_item)>0){
		copy_item(&max_item,&r->right->item);
	}
	copy_item(&r->item,&max_item);

	return(r);
}
/*
** This implementation of shuffle operation does not use an auxiliary array. But
** it uses a brute force method, which is not so elegant. This method uses the same idea
** as shuffling a deck: we divide the deck into two halves, and take one top card from
** each half every time, and add them to the result card heap. In this implementation,
** we main the result heap form array[left] to array[i-1], the first half from array[i]
** to array[j-1], and the second half from array[j] to array[right]. Every time we take
** an element from one of the two halves into position array[i], increment i,then adjust 
** the array to maintain the property above. When we reach the right end, the whole array
** will be shuffled.
*/
void shuffle(item_t *array,int left,int right)
{
	int i,j,k;
	int middle=(left+right)/2;
	item_t t;

	if(right-left+1<=2){
		return;
	}

	for(j=middle+1,i=left;i<=right;i++){
		if((i-left)%2==0){
			continue;
		}
		if((i-left)%2==1){
			copy_item(&t,&array[j]);
			
			for(k=j;k>i;k--){
				copy_item(&array[k],&array[k-1]);
			}
	
			copy_item(&array[i],&t);
			j++;
		}
	}
}
/*
** This implementation of unshuffle operation does not use an auxiliary array, by the brute force
** method. This method maintains the following property: the first resultant half is between
** array[left] and array[m], the second resultant half is from array[m+1] and array[i-1], and the
** original shuffled part is from array[i] and array[right].
*/
void unshuffle(item_t *array,int left,int right)
{
	int i,j,m;
	item_t t;

	if(right-left+1<=2){
		return;
	}

	for(m=0,i=left+2;i<=right;i++){
		if((i-left)%2==1){
			continue;
		}
		if((i-left)%2==0){
			copy_item(&t,&array[i]);

			for(j=i;j>m+1;j--){
				copy_item(&array[j],&array[j-1]);
			}

			copy_item(&array[j],&t);
			m++;
		}
	}
}
/*
** This lsd_radixsort implementation uses a stable sorting method to make
** the w-th byte in order. We use two traversing pointer i, j to find bit
** 0 and 1 in the byte, and put them in the right places in the auxiliary
** array aux from both ends, pointed to by p and q. When the traverse is 
** finished, then the w-th byte is in order. This method is stable, but it
** can only sorts the byte that just has 1 bit in size, whose value is either
** 0 or 1.
*/
void lsd_radixsort(item_t *array,int left,int right)
{
	int i,j;
	int p,q;
	int w;
	int n=right-left+1;
	item_t *aux;

	if(right-left+1<=1){
		return;
	}


	aux=malloc(n*sizeof(*aux));

	for(w=bytesword-1;w>=0;w--){
		p=0;
		q=n-1;
		for(i=left,j=right;i<=right;i++,j--){
			if(digit(array[i],w)==0){
				copy_item(&aux[p++],&array[i]);
			}
			if(digit(array[j],w)==1){
				copy_item(&aux[q--],&array[j]);
			}
		}

		for(i=left;i<=right;i++){
			copy_item(&array[i],&aux[i-left]);
		}
	}

	free(aux);
}
link_t new_node(item_t item)
{
	link_t x=malloc(sizeof(*x));
	x->next=NULL;
	copy_item(&(x->item),&item);
	
	return(x);
}
示例#8
0
文件: flexarray.c 项目: jff/mathspad
int fx_set(FlexArray *fl, int pos, void *item)
{
    if (pos<0) return 0;
    if (pos>=fl->nr && !expand_flex(fl,fl->nr)) return 0;
    if (pos>=fl->nr) pos = fl->nr;
    copy_item((char*)fl->arr+pos*fl->size, (char*)item, fl->size);
    if (pos==fl->nr) fl->nr++;
    return pos+1;
}
void do_msd_radixsort(item_t *array,int left,int right,int w)
{
	int n=right-left+1;
	item_t *aux;
	int count[R+1];
	int i;

	if(right-left+1<=1 || w>=bytesword){
		return;
	}


	for(i=0;i<=R;i++){
		count[i]=0;
	}

	for(i=left;i<=right;i++){
		count[digit(array[i],w)+1]++;
	}

	for(i=1;i<=R;i++){
		count[i]+=count[i-1];
	}


	aux=malloc(n*sizeof(*aux));

	for(i=left;i<=right;i++){
		copy_item(&aux[count[digit(array[i],w)]++],&array[i]);
	}

	for(i=left;i<=right;i++){
		copy_item(&array[i],&aux[i-left]);	
	}

	free(aux);

	
	do_msd_radixsort(array,left,left+count[0]-1,w+1);
	for(i=1;i<R;i++){
		do_msd_radixsort(array,left+count[i-1],left+count[i]-1,w+1);		
	}
}
void insertion_sort_radix(item_t *array,int left,int right,int w)
{
    int i,j;
    item_t t;

    for(i=left+1; i<=right; i++) {
        copy_item(&t,&array[i]);

        for(j=i; j>left; j--) {
            if(digit(array[j-1],w)<=digit(t,w)) {
                break;
            }

            copy_item(&array[j],&array[j-1]);
        }

        copy_item(&array[j],&t);
    }
}
示例#11
0
bool database::Database::set_item(struct TItemStData *data)
{
	bool res = false;
	if (items.size() < ITEM_STORAGE_SIZE)
	{
		items.resize(items.size() + 1);
		copy_item(data, &(items[items.size() - 1]));
		res = true;
	}
	return res;
}
示例#12
0
// The file pointer of the start of the record will be appended to all receiver items 'data_place' fields 
// Then all items will be appended to the common queue
void CFStream::appendDelayedItems(const ReceiverItems& receiver_items_from_record, const SourceItems& source_items_from_record)
{
	const unsigned int record_start_pointer = static_cast<unsigned int>(getStreamPointer()) - sizeof(unsigned short)/*size_short*/ - sizeof(CFRecordType::TypeId);

	for(ReceiverItems::const_iterator it = receiver_items_from_record.begin(), itEnd = receiver_items_from_record.end(); it != itEnd; ++it)
	{
		ReceiverItem copy_item(*it);
		copy_item.data_place += record_start_pointer;
		receiver_items.push_back(copy_item);
	}
	for(SourceItems::const_iterator it = source_items_from_record.begin(), itEnd = source_items_from_record.end(); it != itEnd; ++it)
	{
		SourceItem copy_item(*it);
		if(copy_item.is_file_ptr)
		{
			copy_item.data += record_start_pointer;
		}
		source_items.push_back(copy_item);
	}
}
item_t pqueue_del_max(pqueue_t pq)
{
	item_t max_item;

	assert(!pqueue_empty(pq));

	copy_item(&max_item,&pq->root->item);
	pq->root=do_pqueue_del_max(pq->root);

	return(max_item);
}
void lsd_radixsort(item_t *array,int left,int right)
{
	int i;
	int w;
	int n=right-left+1;
	int count[R+1];
	item_t *aux;

	if(right-left+1<=1){
		return;
	}


	aux=malloc(n*sizeof(*aux));

	for(w=bytesword-1;w>=0;w--){
		for(i=0;i<=R;i++){
			count[i]=0;
		}
	
		for(i=left;i<=right;i++){
			count[digit(array[i],w)+1]++;
		}
	
		for(i=1;i<=R;i++){
			count[i]+=count[i-1];
		}


		for(i=left;i<=right;i++){
			copy_item(&aux[count[digit(array[i],w)]++],&array[i]);
		}
	
		for(i=left;i<=right;i++){
			copy_item(&array[i],&aux[i-left]);	
		}
	}

	free(aux);
}
示例#15
0
文件: flexarray.c 项目: jff/mathspad
/*void fx_insert(FlexArray *fl, int pos, void *item)
{
    if (pos<0) pos=0;
    if (pos>=fl->nr)
	if (expand_flex(fl,fl->nr+1))
	    pos=fl->nr;
	else
	    return;
    if (pos<fl->nr)
	memfwd((char*)fl->arr+fl->nr*fl->size,
	       (char*)fl->arr+(fl->nr-1)*fl->size,
	       (char*)fl->arr+pos*fl->size); 
    copy_item((char*)fl->arr+pos*fl->size, (char*)item, fl->size);
}
*/
int fx_switch(FlexArray *fl, void *olditem, void *newitem)
{
    int i,changed=0;
    i=0;
    while (i<fl->nr) {
	if (!fl->comp((char*)fl->arr+i*fl->size, olditem)) {
	    copy_item((char*)fl->arr+i*fl->size, (char*)newitem, fl->size);
	    changed=i+1;
	}
	i++;
    }
    return changed;
}
static pqueue_link_t do_pqueue_del_max(pqueue_link_t r)
{
	item_t max_item;
	pqueue_link_t t;

	if(r->left==NULL && r->right==NULL){
		free(r);
		return(NULL);
	}

	if(compare_item(r->left->item,r->item)==0){
		r->left=do_pqueue_del_max(r->left);

		if(r->left==NULL){
			t=r->right;
			free(r);
			return(t);
		}
	}else{
		r->right=do_pqueue_del_max(r->right);

		if(r->right==NULL){
			t=r->left;
			free(r);
			return(t);
		}
	}

	copy_item(&max_item,&r->left->item);
	if(compare_item(r->right->item,max_item)>0){
		copy_item(&max_item,&r->right->item);
	}
	copy_item(&r->item,&max_item);

	return(r);
}
示例#17
0
文件: 2ASM_4_24.cpp 项目: chenc10/FIT
Tnode * step_split_samelevel(Tree * MTree, Tnode * Brother)
{//spliting of the same level 
	Tnode * Created;
	MMostItem.MaxNum = 0;
	MMostItem.MItem = NULL;
	int s = 0;
	Created = (Tnode *)malloc(sizeof(Tnode));
	for( int i = 0; i < Brother->TTransactionNum; i ++)
		for( int j = 0; j < 5; j ++)
			for( int k = 0; k < Brother->TTransaction[i].PacketNum[j]; k ++)
				if(!(Brother->TTransaction[i].ItemArray[j][k].IsVisited))
					{
					for( int l = 0; l < Brother->TLevel -1; l ++)
						if(( j == Brother->TItem[l].PacketSeqNum ) &&( k == Brother->TItem[l].ByteSeqNum) && !strcmp(Brother->TTransaction[i].ItemArray[j][k].Pload,Brother->TItem[l].Pload))
							s = 1;
					if(s == 1)
						{
						s = 0;
						continue;
						}
					calculate_support(Brother->TTransaction[i].ItemArray[j]+k,Brother);
					}

					
	/*for( int i = 0; i < Brother->TTransactionNum; i ++)
	{
		for( int j= 0,s = 0; j < Brother->TTransaction[i].ItemNum; j ++)
		{
			if(!(Brother->TTransaction[i].ItemArray[j].IsVisited))
			{
				for( int k = 0; k < Brother->TLevel - 1; k ++)
					if( (j == Brother->TItem[k].ISeqNum) && !strcmp(Brother->TTransaction[i].ItemArray[j].Pload,Brother->TItem[k].Pload))
						s = 1;
				if(s == 1)
				{
					s = 0;
					continue;
				}
				calculate_support(Brother->TTransaction[i].ItemArray + j,Brother);
			}
		}
	}*/
	for( int i = 0; i < Brother->TTransactionNum; i ++)
		for( int j = 0; j < 5; j ++)
			for( int k = 0; k < Brother->TTransaction[i].PacketNum[j]; k ++)
				{
				Brother->TTransaction[i].ItemArray[j][k].IsVisited = 0;
				Brother->TTransaction[i].ItemArray[j][k].VisitedTimes = 0;
				}
			/*
		for( int j = 0; j < Brother->TTransaction[i].ItemNum; j ++)
		{
			Brother->TTransaction[i].ItemArray[j].IsVisited = 0;//reset
			Brother->TTransaction[i].ItemArray[j].VisitedTimes = 0;
		}*/

	

	Transaction  * BTransaction;
	BTransaction = (Transaction *)malloc(MMostItem.MaxNum*sizeof(Transaction));
	Item * BItem;
	BItem = (Item *)malloc( (Brother->TLevel)*sizeof(Item));
	//
	Brother->ChildTnodeArray = 0;
	Brother->ChildTnodeNum = 0;
	Brother->NextTnode = Created;
	for(int i = 0; i < Brother->TLevel - 1; i ++)
		copy_item(BItem+i,Brother->TItem + i);
	copy_item(BItem + Brother->TLevel - 1,MMostItem.MItem);
	Brother->TItem = BItem;
	
	//dealing with the newly created nodes
	Item * CItem;
	CItem = (Item *)malloc( (Brother->TLevel - 1) * sizeof(Item));
	//
	Created->TTransactionNum = Brother->TTransactionNum - MMostItem.MaxNum;
	Created->TTransaction = (Transaction *)malloc(Created->TTransactionNum * sizeof(Transaction));
	Created->ChildTnodeArray = 0;
	Created->ChildTnodeNum = 0;
	Created->FatherTnode = Brother->FatherTnode;
	Created->PreviousTnode = Brother;
	Created->NextTnode = 0;
	for(int i = 0; i < Brother->TLevel - 1; i ++)
		copy_item(CItem+i,Brother->TItem + i);
	Created->TItem = CItem;
	Created->TLevel = Brother->TLevel;
	MTree->TnodeNum ++;
	Created->TSerialNum = MTree->TnodeNum;//we need to record the sequential number of a newly createdly node

	Brother->FatherTnode->ChildTnodeNum ++;

	for( int i = 0,j = 0,k = 0; i < Brother->TTransactionNum; i ++)
		if( Brother->TTransaction[i].PacketNum[MMostItem.MItem->PacketSeqNum] > MMostItem.MItem->ByteSeqNum && !strcmp(Brother->TTransaction[i].ItemArray[MMostItem.MItem->PacketSeqNum][MMostItem.MItem->ByteSeqNum].Pload,MMostItem.MItem->Pload))
		{
			BTransaction[j].ItemArray = Brother->TTransaction[i].ItemArray;
			BTransaction[j].PacketNum = Brother->TTransaction[i].PacketNum;
			j ++;
		}
		else
		{
			Created->TTransaction[k].ItemArray = Brother->TTransaction[i].ItemArray;
			Created->TTransaction[k].PacketNum= Brother->TTransaction[i].PacketNum;
			k ++;
		}

	Brother->TTransactionNum = MMostItem.MaxNum;
	Brother->TTransaction = BTransaction;

	return Created;
}
示例#18
0
文件: 2ASM_4_24.cpp 项目: chenc10/FIT
//all spliting can be regarded as two kinds: the spliting of the same level and the spliting acrossing levels
void step_split_differentlevel(Tree * MTree, Tnode * Root, Tnode * Created1, Tnode * Created2)
{//deviding the Transactions into to clusters and save them into Created1 and Created2 irrespectively

	MMostItem.MaxNum = 0;
	MMostItem.MItem = NULL;
	for( int i = 0, s = 0; i < Root->TTransactionNum; i ++)
		//get the item as the most frequent item
		for( int j = 0; j < 5; j ++)
			for( int k = 0; k < Root->TTransaction[i].PacketNum[j]; k ++)
				if(!(Root->TTransaction[i].ItemArray[j][k].IsVisited))
					{
					for( int l = 0; l < Root->TLevel; l ++)
						if(( j == Root->TItem[l].PacketSeqNum ) && ( k == Root->TItem[l].ByteSeqNum) && !(strcmp(Root->TTransaction[i].ItemArray[j][k].Pload,Root->TItem[l].Pload)))
							{
							s = 1;
							break;
							}
					if(s == 1)
						{
						s = 0;
						continue;
						}
					calculate_support(Root->TTransaction[i].ItemArray[j]+k,Root);
					}
			

		/*for( int j= 0,s = 0; j < Root->TTransaction[i].PacketNum; j ++)
		{
		for( 
			if(!(Root->TTransaction[i].ItemArray[j].IsVisited))
			{
				for( int k = 0; k < Root->TLevel; k ++)
					if((j == Root->TItem[k].ISeqNum) && !(strcmp(Root->TTransaction[i].ItemArray[j].Pload,Root->TItem[k].Pload)))
					{
						s = 1;//if an item has already become a feature item in its father, we then ignore it
						break;
					}
				if(s == 1)
				{
					s = 0;
					continue;
				}
				calculate_support(Root->TTransaction[i].ItemArray + j,Root);
			}
		}*/

	for( int i = 0; i < Root->TTransactionNum; i ++)
		for( int j = 0; j < 5; j ++)
			for( int k = 0; k < Root->TTransaction[i].PacketNum[j]; k ++)
				{
				Root->TTransaction[i].ItemArray[j][k].IsVisited = 0;
				Root->TTransaction[i].ItemArray[j][k].VisitedTimes = 0;
				}
	Created1->TTransactionNum = MMostItem.MaxNum;
	Created1->TTransaction = (Transaction *)malloc(Created1->TTransactionNum * sizeof(Transaction));
	Created1->ChildTnodeArray = NULL;
	Created1->ChildTnodeNum = 0;
	Created1->FatherTnode = Root;
	Created1->PreviousTnode = NULL;
	Created1->NextTnode = Created2;
	//copy the object
	Created1->TItem = (Item *)malloc((Root->TLevel + 1)*sizeof(Item));
	for( int i = 0; i < Root->TLevel; i ++)
		copy_item(Created1->TItem + i,Root->TItem + i);
	copy_item(Created1->TItem + Root->TLevel, MMostItem.MItem);
	//
	Created1->TLevel = Root->TLevel + 1;
	MTree->TnodeNum ++;
	Created1->TSerialNum = MTree->TnodeNum;


	//record the features of Created2
	Created2->TTransactionNum = Root->TTransactionNum - MMostItem.MaxNum;
	Created2->TTransaction = (Transaction *)malloc(Created2->TTransactionNum * sizeof(Transaction));
	Created2->ChildTnodeArray = NULL;
	Created2->ChildTnodeNum = 0;
	Created2->FatherTnode = Root;
	Created2->PreviousTnode = Created1;
	Created2->NextTnode = NULL;
	//
	Created2->TItem = (Item *)malloc(Root->TLevel * sizeof(Item));
	for( int i = 0; i < Root->TLevel; i ++)
		copy_item(Created2->TItem + i,Root->TItem + i);
	//
	Created2->TLevel = Root->TLevel + 1;
	MTree->TnodeNum ++;
	Created2->TSerialNum = MTree->TnodeNum;//MTree->TnodeNum;

	Root->ChildTnodeNum = 1;
	Root->ChildTnodeArray = (Tnode **)malloc( (Root->ChildTnodeNum) * sizeof(Tnode *));
	Root->ChildTnodeArray[0] = Created1;
	
	//spliting the Transactions
	for( int i = 0,j = 0,k = 0; i < Root->TTransactionNum; i ++)
		if( Root->TTransaction[i].PacketNum[MMostItem.MItem->PacketSeqNum] > MMostItem.MItem->ByteSeqNum && !strcmp(Root->TTransaction[i].ItemArray[MMostItem.MItem->PacketSeqNum][MMostItem.MItem->ByteSeqNum].Pload,MMostItem.MItem->Pload))
		{
			Created1->TTransaction[j].ItemArray = Root->TTransaction[i].ItemArray;
			Created1->TTransaction[j].PacketNum = Root->TTransaction[i].PacketNum;
			j ++;
		}
		else
		{
			Created2->TTransaction[k].ItemArray = Root->TTransaction[i].ItemArray;
			Created2->TTransaction[k].PacketNum = Root->TTransaction[i].PacketNum;
			k ++;
		}
}
示例#19
0
        static void add_copy_items(PragmaCustomLine construct, 
                DataEnvironment& data_sharing_environment,
                const ObjectList<Nodecl::NodeclBase>& list,
                TL::OmpSs::CopyDirection copy_direction,
                TL::OmpSs::TargetInfo& target_info,
                bool in_ompss_mode)
        {
            TL::ObjectList<TL::OmpSs::CopyItem> items;

            for (ObjectList<Nodecl::NodeclBase>::const_iterator it = list.begin();
                    it != list.end();
                    it++)
            {
                DataReference expr(*it);

                std::string warning;
                if (!expr.is_valid())
                {
                    expr.commit_diagnostic();
                    warn_printf_at(construct.get_locus(), "'%s' is not a valid copy data-reference, skipping\n",
                            expr.prettyprint().c_str());
                    continue;
                }

                // In OmpSs copies we may fix the data-sharing to something more natural
                if (in_ompss_mode)
                {
                    Symbol sym = expr.get_base_symbol();
                    // In OmpSs, the storage of a copy is always SHARED. Note that with this
                    // definition we aren't defining the data-sharings of the variables involved
                    // in that expression.
                    //
                    // About the data-sharings of the variables involved in the copy expression:
                    // - Fortran: the base symbol of the copy expression is always SHARED
                    // - C/C++:
                    //  * The base symbol of a trivial copy (i.e the expression is a symbol) must always be SHARED:
                    //          int x, a[10];
                    //          copy_inout(x) -> shared(x)
                    //          copy_inout(a) -> shared(a)
                    //  * The base symbol of an array expression or a reference to an array must be SHARED too:
                    //          copy_int a[10];
                    //          copy_inout(a[4])   -> shared(a)
                    //          copy_inout(a[1:2]) -> shared(a)
                    //  * The base symbol of a class member access must be shared too:
                    //          struct C { int z; } c;
                    //          copy_inout(c.z)       -> shared(c)
                    //  * Otherwise, the data-sharing of the base symbol is FIRSTPRIVATE:
                    //          int* p;
                    //          copy_inout(*p)     -> firstprivate(p)
                    //          copy_inout(p[10])  -> firstprivate(p)
                    //          copy_inout(p[1:2]) -> firstprivate(p)
                    //          copy_inout([10][20] p) -> firstprivate(p)
                    if (IS_FORTRAN_LANGUAGE)
                    {
                        data_sharing_environment.set_data_sharing(sym, DS_SHARED, DSK_IMPLICIT,
                                "the variable is mentioned in a copy and it did not have an explicit data-sharing");
                    }
                    else if (expr.is<Nodecl::Symbol>())
                    {
                        data_sharing_environment.set_data_sharing(sym, DS_SHARED, DSK_IMPLICIT,
                                "the variable is mentioned in a copy and it did not have an explicit data-sharing");
                    }
                    else if (sym.get_type().is_array()
                            || (sym.get_type().is_any_reference()
                                && sym.get_type().references_to().is_array()))
                    {
                        data_sharing_environment.set_data_sharing(sym, DS_SHARED, DSK_IMPLICIT,
                                "the variable is an array mentioned in a non-trivial copy "
                                "and it did not have an explicit data-sharing");
                    }
                    else if (sym.get_type().is_class())
                    {
                        data_sharing_environment.set_data_sharing(sym, DS_SHARED, DSK_IMPLICIT,
                                "the variable is an object mentioned in a non-trivial dependence "
                                "and it did not have an explicit data-sharing");
                    }
                    else
                    {
                        data_sharing_environment.set_data_sharing(sym, DS_FIRSTPRIVATE, DSK_IMPLICIT,
                                "the variable is a non-array mentioned in a non-trivial copy "
                                "and it did not have an explicit data-sharing");
                    }
                }

                TL::OmpSs::CopyItem copy_item(expr, copy_direction);
                items.append(copy_item);
            }

            switch (copy_direction)
            {
                case TL::OmpSs::COPY_DIR_IN:
                    {
                        target_info.append_to_copy_in(items);
                        break;
                    }
                case TL::OmpSs::COPY_DIR_OUT:
                    {
                        target_info.append_to_copy_out(items);
                        break;
                    }
                case TL::OmpSs::COPY_DIR_INOUT:
                    {
                        target_info.append_to_copy_inout(items);
                        break;
                    }
                default:
                    {
                        internal_error("Unreachable code", 0);
                    }
            }
        }
示例#20
0
文件: flexarray.c 项目: jff/mathspad
void fx_add(FlexArray *fl, void *item)
{
    if (!expand_flex(fl, fl->nr)) return;
    copy_item((char*)fl->arr+fl->nr*fl->size, (char*)item, fl->size);
    fl->nr++;
}
示例#21
0
void nemo_main(void)
{
    stream instr, outstr, nullstr;
    string item, *items;
    string *tags, *sels, *cvt;
    int    i, nsel, select[MAXSEL], cntrd, cntwr;
    bool all;

    instr = stropen(getparam("in"), "r");
    nullstr = stropen("/dev/null","w+");        /* kludge: force write */
    item = getparam("item");
    sels = burststring(getparam("select"),", ");
    nsel = xstrlen(sels, sizeof(string)) - 1;
    for (i=0; i<nsel; i++) {		/* note: array should be sorted */
        select[i] = atoi(sels[i]);
	dprintf(1,"#selected #%d\n",select[i]);
	if (select[i]<1)
            error("%d: bad number for select=, must be > 0",select[i]);
        if (i>0 && (select[i]<select[i-1]))
            error("%d: bad number for select=, array must be sorted",select[i]);
    }
    cvt = burststring(getparam("convert"),", ");

    if (*item == 0) {
        all = TRUE;
	items = (string *) allocate(sizeof(string));    /* PPAP */
	items[0] = NULL;
    } else {
        all = FALSE;
        items = burststring(item,", ");
        if (items==NULL)
            error("error parsing item=%s\n",item);
        dprintf(1,"selected: ");
        for (i=0; items[i]!=NULL; i++)
            dprintf(1," %s",items[i]);
        dprintf(1,"\n\n");
    }
    outstr = stropen(getparam("out"), "w");
    cntrd = 0;      /* keep track of items read */
    cntwr = 0;      /* and written */
    while ((tags = list_tags(instr)) != NULL) {
        if (check(items, *tags)) {
            cntrd++;
            dprintf(1," %d: %s",cntrd,*tags);
	    if (nsel==0 || (nsel>0 && select[cntwr] == cntrd)) {
               copy_item_cvt(outstr, instr, *tags, cvt);
               cntwr++;
               dprintf(1," copied\n");
	    } else {
	       copy_item(nullstr, instr, *tags);
               dprintf(1," skipped\n");
            }
        } else {
            dprintf(1," *: %s",*tags);        	
	    copy_item(nullstr, instr, *tags);
            dprintf(1," skipped\n");
        }
	free((char *)*tags);
	free((char *)tags);
        if (nsel>0 && cntwr >= nsel)     /* early bailout ? */
            break;
    }
    dprintf(0,"On top-level: %d items  read, %d items written\n",cntrd,cntwr);
    strclose(instr);
    strclose(outstr);
}
void pqueue_insert(item_t item)
{
	copy_item(&pq[++N],&item);
	heapify_bottom_up(pq,N);
}
void pqueue_insert(item_t item)
{
	copy_item(&pq[N++],&item);
}