2.2.3.19.41 vectorbase::TrimLeftTrimLeft
Description
Removes elements having the missing value (NANUM) from the left end of the vector.
Syntax
int TrimLeft( BOOL bShiftLeft = FALSE )
Parameters
- bShiftLeft
- [input] TRUE will delete cells on the left of (before) the first valid numeric value, FASLE will cause the lower bound or index to be adjusted upward but no cells are deleted.
Return
Returns -1 on error, 0 on success, and N > 0 for number of cells deleted.
Examples
EX1
//Case1: bShiftLeft = FALSE using in vector. will keep the vector not delete NANUM
void vectorbase_TrimLeft_ex1()
{
vector vecData = {0.1, 0.2, 0.3, 0.4};
vecData[0] = NANUM;
// vecData = {NANUM, 0.2, 0.3, 0.4}
// Now using function trimleft to trim the vector's left
vecData.TrimLeft();
for(int ii = 0; ii < vecData.GetSize(); ii++)
out_double("",vecData[ii]);
// Result:
// vecData = {NANUM, 0.2, 0.3, 0.4}
}
EX2
//Case2: bShiftLeft = TRUE using in vector. will Remove Left NANUM
void vectorbase_TrimLeft_ex2()
{
vector vecData = {0.1, 0.2, 0.3, 0.4};
vecData[0] = NANUM;
vecData[1] = NANUM;
// vecData = {NANUM, NANUM, 0.3, 0.4}
// Now using function trimleft to trim the vector's left
int nRet = vecData.TrimLeft(true);
for(int ii = 0; ii < vecData.GetSize(); ii++)
out_double("",vecData[ii]);
// Result:
// vecData = {0.3, 0.4}
}
EX3
void vectorbase_TrimLeft_ex3()
{
// The current window is Worksheet with two columns
Worksheet wks=Project.ActiveLayer();
if (wks)
{
Dataset dsA(wks,0);
Dataset dsB(wks,1);
dsA.TrimLeft(TRUE);
Curve crvAxBy(dsA,dsB);
crvAxBy.TrimLeft(TRUE);
LT_execute("doc -uw");
}
}
EX4
//Case4: bShiftLeft = TRUE in Curve.
void vectorbase_TrimLeft_ex4()
{
vector vX = {1, 2, 3, 4};
vector vY = {0.1, 0.2, 0.3, 0.4};
vX[0] = NANUM;
vX[1] = NANUM;
Curve crv(vX, vY);
// crv = {(NANUM,0.1), (NANUM,0.2), (3,0.3),(4, 0.4)}
// Now using function trimleft to trim the Curve's left
crv.TrimLeft(true);
// Result:
// crv = {(3,0.3),(4, 0.4)}
}
Remark
TrimLeft removes elements having the missing value from the left end or beginning of the vectorbase derived object by advancing the lower index to the first valid numeric value. If bShiftLeft is TRUE cells containing NANUM are deleted from the vectorbase object and a lower index value of 0 is returned shifting numeric values left. bShiftLeft must be TRUE. For vectors or this function will have no effect. When bShiftLeft is TRUE TrimLeft of Curve objects causes both X and Y Datasets to be trimmed.
See Also
vectorbase::Trim, vectorbase::TrimRight, vectorbase::GetLowerBound, vector::vector
Header to Include
origin.h
|