I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.36
sub units 0.00
+
0
ComputingArray

Vector

viewed 8986 times and licensed 122 times
Dynamically allocates a 1D block (vector) of data.
Controller: CodeCogs

Interface

C++

Vector

 
template<class T> T*vectorlongColumns )[inline]
Dynamically allocates a zero-based 1D block of memory. This memory block is continuous.

MISSING IMAGE!

1/vector-969.png cannot be found in /users/1/vector-969.png. Please contact the submission author.

The more traditional equivalent of this function is simply <tt>new</tt>, for example:
char* a=vector<char>(11);
is nearly (see code) identical to:
char* a=new char[11];

You may use <em> free_vector </em> with default argment to deallocate memory allocated to this structure, alternatively you can use the more traditional C++ approach: <tt>delete[](..)</tt>

Parameters

ColumnsThe length of the vector.
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.


Vector

 
template<class T> T*vectorlongColumns_start
longColumns_end )[inline]
Dynamically allocates a 1D block of memory, to contain components within the specifed range (inclusive). This memory block is continuous.
MISSING IMAGE!

1/vector-969.png cannot be found in /users/1/vector-969.png. Please contact the submission author.

Example 1

#include <codecogs/array/vector.h>
 
int main()
{
double *a = Array::vector<double>(1,10);
a[1]=23.4;
a[10]=56.7;
Array::free_vector(a, 1);
int *b = Array::vector<int>(20,30);
b[20]=4;
b[30]=5;
Array::free_vector(b, 20);
return 0;
}

Note

You must use <em> free_vector </em> to deallocate memory allocated to this structure.

Parameters

Columns_startThe first addressible index.
Columns_endThe last addressible index.
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.


Free Vector

 
template<class T> voidfree_vectorT*Vector
intoffset = 0 )[inline]
Removes any dynamically allocated memory from the stack. Can be used on virtually any 1D array. This function is provided for completeness, but is identical to <tt>delete[](...)</tt>. We recomend you use delete is most situations.

The opposite of this function is <em> vector </em>

Parameters

Vectoris the 1D data structure to delete.
offsetis the original offset to the first element in the array, if not zero (default=0).
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.