本文整理汇总了C++中DataVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ DataVector::push_back方法的具体用法?C++ DataVector::push_back怎么用?C++ DataVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataVector
的用法示例。
在下文中一共展示了DataVector::push_back方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_datafilters
/**
* Test DataFilters
*/
void test_datafilters()
{
std::vector<std::string> datas;
datas.push_back("1");
datas.push_back("2");
datas.push_back("3");
DataVector datav;
datav.push_back(DataPoint(1,true));
datav.push_back(DataPoint(2,true));
datav.push_back(DataPoint(3,true));
DataFilters filters;
ASSERT(filters.isFiltered(datas), "DataFilters::isFiltered failed on string vector with no filter");
ASSERT(filters.isFiltered(datav), "DataFilters::isFiltered failed on data vector with no filter");
filters.addNumericFilter(0,1,1,true);
ASSERT(filters.isFiltered(datav), "DataFilters::isFiltered failed on data vector with numeric accepting filter on 0");
filters.addNumericFilter(1,4,4,false);
ASSERT(filters.isFiltered(datav), "DataFilters::isFiltered failed on data vector with numeric rejection filter on 1");
filters.addStringFilter(0,"1",true,true,true);
ASSERT(filters.isFiltered(datas), "DataFilters::isFiltered failed on data vector with string accepting filter on 0");
filters.addStringFilter(1,"4",true,true,false);
ASSERT(filters.isFiltered(datas), "DataFilters::isFiltered failed on data vector with string rejection filter on 1");
}
示例2: expand_cluster_order
/** Expands the cluster order while adding new neighbor points to the order.
* @param db All data points that are to be considered by the algorithm. Changes their values.
* @param p The point to be examined.
* @param eps The epsilon representing the radius of the epsilon-neighborhood.
* @param min_pts The minimum number of points to be found within an epsilon-neigborhood.
* @param[out] o_ordered_vector The ordered vector of data points. Elements will be added to this vector.
*/
void expand_cluster_order( DataVector& db, DataPoint* p, const real eps, const unsigned int min_pts, DataVector& o_ordered_vector) {
assert( eps >= 0 && "eps must not be negative");
assert( min_pts > 0 && "min_pts must be greater than 0");
DataVector N_eps = get_neighbors( p, eps, db);
p->reachability_distance( OPTICS::UNDEFINED);
const real core_dist_p = squared_core_distance( p, min_pts, N_eps);
p->processed( true);
o_ordered_vector.push_back( p);
if( core_dist_p == OPTICS::UNDEFINED)
return;
DataSet seeds;
update_seeds( N_eps, p, core_dist_p, seeds);
while( !seeds.empty()) {
DataPoint* q = *seeds.begin();
seeds.erase( seeds.begin()); // remove first element from seeds
DataVector N_q = get_neighbors( q, eps, db);
const real core_dist_q = squared_core_distance( q, min_pts, N_q);
q->processed( true);
o_ordered_vector.push_back( q);
if( core_dist_q != OPTICS::UNDEFINED) {
// *** q is a core-object ***
update_seeds( N_q, q, core_dist_q, seeds);
}
}
}
示例3: test_datavector
/**
* Test DataVector
*/
void test_datavector()
{
DataVector src;
src.push_back(DataPoint(1,true));
src.push_back(DataPoint(2,true));
src.push_back(DataPoint(3,true));
std::vector<bool> mask(3,true);
DataVector dst;
dst.copy(src,mask);
ASSERT_EQUAL(dst.at(0).value, 1, "DataVector::copy value failed on enabled data point at 0");
ASSERT(dst.at(0).active, "DataVector::copy active failed on enabled data point at 0");
ASSERT_EQUAL(dst.at(1).value, 2, "DataVector::copy value failed on enabled data point at 1");
ASSERT(dst.at(1).active, "DataVector::copy active failed on enabled data point at 1");
ASSERT_EQUAL(dst.at(2).value, 3, "DataVector::copy value failed on enabled data point at 2");
ASSERT(dst.at(2).active, "DataVector::copy active failed on enabled data point at 2");
src.deactivate();
dst.clear();
dst.copy(src,mask);
ASSERT_EXCEPTION(dst.at(0), "DataVector::copy failed on disabled data point at 0");
ASSERT_EXCEPTION(dst.at(1), "DataVector::copy failed on disabled data point at 1");
ASSERT_EXCEPTION(dst.at(2), "DataVector::copy failed on disabled data point at 2");
}
示例4: main
int main(int argc, char *argv[])
{
struct shm_remove
{
shm_remove() { boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
~shm_remove(){ boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
} remover;
boost::interprocess::managed_shared_memory segment(boost::interprocess::create_only, "MySharedMemory", 65536);
const ShmemAllocator alloc_inst (segment.get_segment_manager());
DataVector *myvector = segment.construct<DataVector>("MyVector")(alloc_inst);
for(int i = 0; i < 6; ++i) { //Insert data in the vector
printf("%d ", i);
myvector->push_back(i*3);
}
while(1)
{
for(int i = 0; i < 6; ++i) { //Insert data in the vector
printf("%d ", i);
myvector->at(i) = rand()*rand();
printf("%f ", myvector->at(i));
}
printf("\n");
}
return 0;
};
示例5: convertBufferIntoVector
//notes: after using buffer, this function deletes buffer.
DataVector convertBufferIntoVector(char* buffer){
DataVector ColumnData;
char*p = nextNoneSpacePointer(buffer);
while ('\0' != *p){
std::vector< double > lineData;
lineData.reserve(200);
while ('\n' != *p && '\0' != *p){
std::size_t dataOffset = 0;
char *dataBeginning = p;
while (' ' != *p && '\n' != *p && '\0' != *p) {
++dataOffset;
++p;
}
char *dataBuf = new char[dataOffset + 1];
memcpy(dataBuf, dataBeginning, dataOffset);
dataBuf[dataOffset] = '\0';
double dataValue = atof(dataBuf);
delete[] dataBuf;
lineData.push_back(dataValue);
p = nextNoneSpacePointer(p);
}
if (lineData.size() > 0) ColumnData.push_back(lineData);
if ('\0' != *p) ++p;
}
delete[] buffer;
return ColumnData;
}
示例6: test_mean
void test_mean()
{
DataVector d;
for (int i=1; i<=9; ++i)
d.push_back(i);
unit_assert(d.mean() == 5.0);
}
示例7: get_neighbors
/** Retrieves all points in the epsilon-surrounding of the given data point, including the point itself.
* @param p The datapoint which represents the center of the epsilon surrounding.
* @param eps The epsilon value that represents the radius for the neigborhood search.
* @param db The database consisting of all datapoints that are checked for neighborhood.
* @param A vector of pointers to datapoints that lie within the epsilon-neighborhood
* of the given point p, including p itself.
*/
DataVector get_neighbors( const DataPoint* p, const real eps, DataVector& db) {
assert( eps >= 0 && "eps must not be negative");
DataVector ret;
const real eps_sq = eps*eps;
for( auto q_it=db.begin(); q_it!=db.end(); ++q_it) {
DataPoint* q = *q_it;
if( squared_distance( p, q) <= eps_sq) {
ret.push_back( q);
}
}
return ret;
}
示例8: findMenuByType
int RadialMenuManager::addRootMenu (DataVector & dv, int menuType, const Unicode::String & label, bool serverNotify)
{
if (menuType == 0)
return 0;
const ObjectMenuRequestData * const data = findMenuByType (dv, menuType);
if (data)
return 0;
const uint8 id = findNextId (dv);
dv.push_back (ObjectMenuRequestData (id, 0, static_cast<uint8>(menuType), label, true, serverNotify));
return id;
}