CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components

Valid RSS

Array

Vector

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 0.30
sub units 0.00
add a commercial licence to your cart
0
viewed 8873 times and licensed 109 times

Dynamically allocates a 1D block (vector) of data.

Controller: CodeCogs  Contact Controller
+View version details
Contents hide toc
buy now     get GPL     add to cart

Interface

#include <codecogs/array/vector.h>

using namespace Array;

template<class T> T* vector (long Columns)[inline]
Dynamically allocates a 1D block (vector) of data.
template<class T> T* vector (long Columns_start, long Columns_end)[inline]
Dynamically allocates a 1D block (vector) of data using an offset base memory address.
template<class T> void free_vector (T* Vector, int offset=0)[inline]
Frees from memory a 1D block of dynamically allocated data.

Function Documentation

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

1/vector-969.png
+
Ordering of data
The more traditional equivalent of this function is simply new, for example:
char* a=vector<char>(11);
is nearly (see code) identical to:
char* a=new char[11];

You may use free_vector with default argment to deallocate memory allocated to this structure, alternatively you can use the more traditional C++ approach: delete[](..)
Parameters:
ColumnsThe length of the vector.
Source Code:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

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


 
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.
1/vector-969.png
+
Ordering of data
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 free_vector to deallocate memory allocated to this structure.
Parameters:
Columns_startThe first addressible index.
Columns_endThe last addressible index.
Source Code:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

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


 
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 delete[](...). We recomend you use delete is most situations.

The opposite of this function is vector
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:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

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


Page Comments

Format Excel Equations

  You must login to leave a messge


Last Modified: 6 Sep 09 @ 18:41     Page Rendered: 2010-03-12 04:27:16

Valid CSS!   Valid XHTML 1.0 Transitional