2.2.4.46.23 Worksheet::ExtractOneGroupExtractOneGroup
Description
Vector extraction from a column with grouping information
Syntax
BOOL ExtractOneGroup( vector & v, int nCol, const vector<ushort> & vRowMap, int r1Map, int r1, int r2, ushort nGroupIndex )
Parameters
- v
- [output] Reference to vector to receive data
- nCol
- [input] The column index
- vRowMap
- [input] The output map from the the method MakeGroupEntriesAndRowMap()
- r1Map
- [input] It must match r1 passed to MakeGroupEntriesAndRowMap().
- r1
- [input] Row bounds
- r2
- [input] Row bounds. If r2 = -1 : use the whole column
- r1 must be >= r1Map, and r2 must be less than or equal to r2 passed to MakeGroupEntriesAndRowMap().
- nGroupIndex
- [input] The values inside vRowMap to be used when creating v.
Return
TRUE on success; FALSE on failure
Examples
EX1
// fill worksheet with
// 1 1
// 1 2
// 1 3
// 2 4
// 2 5
// 2 6
// 3 7
// 2 8
// 1 9
// 1 10
// make sure worksheet is active then type
// Worksheet_ExtractOneGroup_Ex1
// make worksheet active again, then type
// Worksheet_ExtractOneGroup_Ex1 2;
// can see both 1 and 2 extracted
void Worksheet_ExtractOneGroup_Ex1(int nGroupVal = 1, int nGroupCol = 0, int nDataCol = 1)
{
Worksheet wks = Project.ActiveLayer();
if(!wks)
return;
Column cc(wks, nGroupCol);
vector<ushort> vRowMap(cc);// assume group col already contain group numeric values like 1,2,3 etc
vector vResult;
if(wks.ExtractOneGroup(vResult, nDataCol, vRowMap, 0, 0, vRowMap.GetSize()-1, nGroupVal))
{
// save result into new wks to view
Worksheet wResult("Test");
if(wResult == NULL)
{
wResult.Create();
wResult.GetPage().Rename("Test");
wResult.SetSize(-1, 0);
}
int nCol = wResult.AddCol();
DataRange dr;
dr.Add("X", wResult, 0, nCol, -1, nCol);
dr.SetData(vResult);
}
else
printf("Fail to extract grouped vectors from column in worksheet!");
}
Remark
See Also
Worksheet::MakeGroupEntriesAndRowMap
Header to Include
origin.h
|