Пример #1
0
void copy_helper (SparseNode * array, int * indicies, int * values, int * sum)
{
  if (array == NULL)
  {
    return;
  }
  indicies[*sum] = array->index;
  values[*sum] = array->value;
  (*sum)++;
  
  copy_helper(array->left, indicies, values, sum);
  copy_helper(array->right, indicies, values, sum);
}
Пример #2
0
	MarshalVar& operator = (const MarshalVar& other)
	{
		if (this != &other)
		{
			copy_helper(other);
		}
		return *this;
	}
Пример #3
0
/*
 * Make a copy of current tree
 */
bool syn_tree::copy(syn_tree &copy) {

	// attempt to copy tree
	bool res = copy_helper(copy, get_root(), -1);

	// return results
	if(res)
		copy.advance_root();
	return res;
}
Пример #4
0
static void copy_over_existing(abts_case *tc, void *data)
{
    apr_status_t rv;
    
    /* make absolutely sure that the dest file doesn't exist. */
    apr_file_remove("data/file_copy.txt", p);
    
    /* This is a cheat.  I don't want to create a new file, so I just copy
     * one file, then I copy another.  If the second copy succeeds, then
     * this works.
     */
    copy_helper(tc, "data/file_datafile.txt", "data/file_copy.txt", 
                APR_FPROT_FILE_SOURCE_PERMS, 0, p);
    
    copy_helper(tc, "data/mmap_datafile.txt", "data/file_copy.txt", 
                APR_FPROT_FILE_SOURCE_PERMS, 0, p);
  
    rv = apr_file_remove("data/file_copy.txt", p);
    APR_ASSERT_SUCCESS(tc, "Couldn't remove copy file", rv);
}
Пример #5
0
static void append_nonexist(abts_case *tc, void *data)
{
    apr_status_t rv;

    /* make absolutely sure that the dest file doesn't exist. */
    apr_file_remove("data/file_copy.txt", p);

    copy_helper(tc, "data/file_datafile.txt", "data/file_copy.txt", 
                APR_FPROT_FILE_SOURCE_PERMS, 0, p);
    rv = apr_file_remove("data/file_copy.txt", p);
    APR_ASSERT_SUCCESS(tc, "Couldn't remove copy file", rv);
}
Пример #6
0
SparseNode * SparseArray_copy(SparseNode * array)
{
  SparseNode * copy = NULL;
  int * indicies = NULL;
  int * values = NULL;
  int sum = 0;
  
  copy_helper(array, indicies, values, &sum);
  
  copy = SparseArray_build(indicies, values, sum);
     
  return copy;
}
Пример #7
0
/*
 * Copy a tree from a given root token
 */
bool syn_tree::copy_helper(syn_tree &copy, token *root, int advance) {

	// check to make sure root token exists
	if(!root)
		return false;

	// add root & all children
	copy.add_child(*root);
	if(advance != -1)
		copy.advance_forward(advance);
	for(unsigned int i = 0; i < root->size(); i++) {
		token *child = root->get_child(i);
		if(!copy_helper(copy, child, i))
			return false;
	}
	if(advance != -1)
		copy.advance_back();
	return true;
}
Пример #8
0
bool ChangeSet::copy(int start, int end, int to)
{ return copy_helper(start, end - start, to); }
Пример #9
0
	MarshalVar (const MarshalVar& other)
	{
		copy_helper(other);
	}