int UtcDaliVectorInt(void)
{
  tet_infoline("Testing Dali::Vector<int>");

  Vector< int > intvector;

  DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION );

  intvector.PushBack( 11 );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(1), intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(2), intvector.Capacity(), TEST_LOCATION );
  DALI_TEST_EQUALS( 11, intvector[ 0 ], TEST_LOCATION );

  intvector.PushBack( 99 );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(2), intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(2), intvector.Capacity(), TEST_LOCATION );
  DALI_TEST_EQUALS( 99, intvector[ 1 ], TEST_LOCATION );

  intvector.PushBack( 34 );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(3), intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(6), intvector.Capacity(), TEST_LOCATION );
  DALI_TEST_EQUALS( 11, intvector[ 0 ], TEST_LOCATION );
  DALI_TEST_EQUALS( 99, intvector[ 1 ], TEST_LOCATION );
  DALI_TEST_EQUALS( 34, intvector[ 2 ], TEST_LOCATION );

  intvector.Clear();
  DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(6), intvector.Capacity(), TEST_LOCATION );
  intvector.PushBack( 123 );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(1), intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( 123, intvector[ 0 ], TEST_LOCATION );
  END_TEST;
}
Example #2
0
// compute the points in the CFG reachable from the entry point.
void GetEntryReachable(BlockCFG *cfg)
{
    // worklist items are reachable points whose outgoing edges have
    // not been examined
    Vector<PPoint> worklist;

    PPoint entry = cfg->GetEntryPoint();
    entry_reach_table->Insert(entry);
    worklist.PushBack(entry);

    while (!worklist.Empty()) {
        PPoint back = worklist.Back();
        worklist.PopBack();

        const Vector<PEdge*>& outgoing = cfg->GetOutgoingEdges(back);
        for (size_t oind = 0; oind < outgoing.Size(); oind++) {
            PEdge *edge = outgoing[oind];
            PPoint next = edge->GetTarget();

            // already did this target
            if (entry_reach_table->Lookup(next))
                continue;

            entry_reach_table->Insert(next);
            worklist.PushBack(next);
        }
    }
}
int main()
{
	Vector <Student>students;

	Vector vector;
	vector.PushBack(5);
	vector.PushBack(3);
	vector.PushBack(1);
	vector.PushBack(8);

	cout << "Is empty: " << vector.IsEmpty() << endl;
	cout << "Size: " << vector.Size() << endl;
	cout << "Vector elements: ";
	for (int i = 0; i < vector.Size(); i++)
		cout << vector.GetAt(i) << ", ";

	cout << endl;
	vector.Sort();
	cout << "Increasing vector: ";
	for (int i = 0; i < vector.Size(); i++)
		cout << vector.GetAt(i) << ", ";

	cout << endl;
	cout << "Is sorted: " << vector.IsSorted() << endl;

	vector.Sort(false);
	cout << "Decreasing vector: ";
	for (int i = 0; i < vector.Size(); i++)
		cout << vector.GetAt(i) << ", ";

	cout << endl;
	cout << "Is sorted: " << vector.IsSorted() << endl;

    return 0;
}
int UtcDaliVectorPushBack(void)
{
  tet_infoline( "Testing Dali::Vector< int* >PushBack(Element)" );

  Vector<unsigned int> vector;
  DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, vector.Capacity(), TEST_LOCATION );

  vector.Reserve( 2u );
  DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( 2u, vector.Capacity(), TEST_LOCATION );

  vector.PushBack( 0u );
  vector.PushBack( 1u );
  vector.PushBack( 2u );

  DALI_TEST_EQUALS( 3u, vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( 6u, vector.Capacity(), TEST_LOCATION );

  vector.PushBack( 3u );

  DALI_TEST_EQUALS( 4u, vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( 6u, vector.Capacity(), TEST_LOCATION );

  DALI_TEST_EQUALS( 0u, vector[0u], TEST_LOCATION );
  DALI_TEST_EQUALS( 1u, vector[1u], TEST_LOCATION );
  DALI_TEST_EQUALS( 2u, vector[2u], TEST_LOCATION );
  DALI_TEST_EQUALS( 3u, vector[3u], TEST_LOCATION );

  END_TEST;
}
int UtcDaliVectorIterate(void)
{
  tet_infoline("Testing Dali::Vector<float>::Begin");

  Vector< float > floatvector;
  DALI_TEST_EQUALS( ZERO, floatvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, floatvector.Capacity(), TEST_LOCATION );

  floatvector.PushBack( 0.9f );
  floatvector.PushBack( 1.1f );
  floatvector.PushBack( 1.2f );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(3), floatvector.Count(), TEST_LOCATION );

  Vector< float >::Iterator iter = floatvector.Begin();
  int index = 0;
  for( ; iter != floatvector.End(); ++iter, ++index )
  {
    std::cout << "value " << *iter << std::endl;
    DALI_TEST_EQUALS( *iter, floatvector[ index ], TEST_LOCATION );
  }
  DALI_TEST_EQUALS( 3, index, TEST_LOCATION );

  iter = std::find( floatvector.Begin(), floatvector.End(), 1.1f );
  DALI_TEST_EQUALS( 1.1f, *iter, TEST_LOCATION );

  floatvector.Clear();
  iter = std::find( floatvector.Begin(), floatvector.End(), 1.1f );
  DALI_TEST_EQUALS( floatvector.End(), iter, TEST_LOCATION );
  END_TEST;
}
int UtcDaliVectorPair(void)
{
  tet_infoline("Testing Dali::Vector< std::pair< int, float > >");

  Vector< std::pair< int, float > > pairvector;
  DALI_TEST_EQUALS( ZERO, pairvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, pairvector.Capacity(), TEST_LOCATION );

  pairvector.PushBack( std::make_pair( 5, 0.1f ) );
  pairvector.PushBack( std::make_pair( 3, 0.2f ) );
  pairvector.PushBack( std::make_pair( 4, 0.3f ) );
  pairvector.PushBack( std::make_pair( 1, 0.4f ) );
  pairvector.PushBack( std::make_pair( 2, 0.5f ) );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(5), pairvector.Count(), TEST_LOCATION );

  Vector< std::pair< int, float > >::Iterator iter = pairvector.Begin();
  int index = 0;
  for( ; iter != pairvector.End(); ++iter, ++index )
  {
    std::cout << "pair " << (*iter).first << ":" << (*iter).second << std::endl;
    DALI_TEST_EQUALS( (*iter).first, pairvector[ index ].first, TEST_LOCATION );
    DALI_TEST_EQUALS( (*iter).second, pairvector[ index ].second, TEST_LOCATION );
  }
  END_TEST;
}
Example #7
0
// marks the points in cfg which are isomorphic to points in the loop_cfg
// invoked by cfg at the specified edge. code in a syntactic loop body
// will be reflected in CFGs for both the loop and its parent if it may
// reach both the recursive loop edge and a loop exit point. this common
// code will be isomorphic between the two CFGs.
void GetLoopIsomorphicPoints(BlockCFG *cfg, PEdge *loop_edge,
                             BlockCFG *loop_cfg)
{
    // mapping from points in cfg to isomorphic points in loop_cfg.
    PPointListHash remapping;

    // worklist items are isomorphic points whose outgoing edges have not
    // been examined.
    Vector<PPoint> worklist;

    PPoint target = loop_edge->GetTarget();
    remapping.Insert(target, loop_cfg->GetEntryPoint());
    cfg->AddLoopIsomorphic(target);
    worklist.PushBack(target);

    while (!worklist.Empty()) {
        PPoint cfg_point = worklist.Back();
        worklist.PopBack();

        PPoint loop_point = remapping.LookupSingle(cfg_point);

        const Vector<PEdge*> &cfg_outgoing =
            cfg->GetOutgoingEdges(cfg_point);
        const Vector<PEdge*> &loop_outgoing =
            loop_cfg->GetOutgoingEdges(loop_point);

        for (size_t eind = 0; eind < cfg_outgoing.Size(); eind++) {
            PEdge *edge = cfg_outgoing[eind];
            PPoint target = edge->GetTarget();

            // check for an existing remapping entry. some isomorphic points have
            // multiple incoming edges. we don't need to check all such incoming
            // edges; if any edge is isomorphic, they all will be.
            if (remapping.Lookup(target, false))
                continue;

            // look for an equivalent outgoing edge from the loop.
            PPoint loop_target = 0;

            for (size_t lind = 0; lind < loop_outgoing.Size(); lind++) {
                PEdge *loop_edge = loop_outgoing[lind];

                if (PEdge::CompareInner(edge, loop_edge) == 0) {
                    loop_target = loop_edge->GetTarget();
                    break;
                }
            }

            if (!loop_target) {
                Assert(edge->IsAssume());
                continue;
            }

            remapping.Insert(target, loop_target);
            cfg->AddLoopIsomorphic(target);
            worklist.PushBack(target);
        }
    }
}
int UtcDaliVectorInsert02(void)
{
  tet_infoline("Testing Dali::Vector<char>::Insert(Iterator,Iterator,Iterator)");

  Vector< char > vector;
  DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, vector.Capacity(), TEST_LOCATION );
  vector.PushBack( 1 );
  vector.PushBack( 2 );
  vector.PushBack( 3 );
  vector.PushBack( 4 );
  vector.PushBack( 5 );

  Vector< char > vector2;
  DALI_TEST_EQUALS( ZERO, vector2.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, vector2.Capacity(), TEST_LOCATION );
  vector2.PushBack( 6 );
  vector2.PushBack( 7 );
  vector2.PushBack( 8 );
  vector2.PushBack( 9 );
  vector2.PushBack( 10 );

  // Test insert at end
  vector.Insert( vector.End(), vector2.Begin(), vector2.Begin() + 1u );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(6), vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 0 ], 1, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 1 ], 2, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 2 ], 3, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 3 ], 4, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 4 ], 5, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 5 ], 6, TEST_LOCATION );

  // Test insert at begin
  vector.Insert( vector.Begin(), vector2.Begin()+1, vector2.Begin() + 2u );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(7), vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 0 ], 7, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 1 ], 1, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 2 ], 2, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 3 ], 3, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 4 ], 4, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 5 ], 5, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 6 ], 6, TEST_LOCATION );

  // Test insert in the middle
  vector.Insert( vector.Begin() + 3, vector2.Begin()+3, vector2.End() );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(9), vector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 0 ], 7, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 1 ], 1, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 2 ], 2, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 3 ], 9, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 4 ], 10, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 5 ], 3, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 6 ], 4, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 7 ], 5, TEST_LOCATION );
  DALI_TEST_EQUALS( vector[ 8 ], 6, TEST_LOCATION );
  END_TEST;
}
Example #9
0
// fill in the body of loophead. points in the body are those which
// are reachable from loophead over non-backedges, and which themselves
// reach a backedge for loophead. note that in the case of loop nesting,
// a point may be contained in the body of multiple loops.
// if any irreducible edges are found (edges incoming to a body point
// other than loophead whose source is not in the body), those edges
// are added to irreducible_edges
void GetLoopBody(BlockCFG *cfg, PPoint loophead,
                 Vector<PEdge*> *irreducible_edges)
{
    Vector<PPoint> *body_list = body_list_table->Lookup(loophead, true);
    Assert(body_list->Empty());

    // worklist items are points which reach a loop backedge but whose
    // incoming edges have not yet been examined.
    Vector<PPoint> worklist;

    const Vector<PEdge*> &head_incoming = cfg->GetIncomingEdges(loophead);
    for (size_t iind = 0; iind < head_incoming.Size(); iind++) {
        PEdge *edge = head_incoming[iind];
        PPoint source = edge->GetSource();

        if (backedge_table->Lookup(edge)) {
            Assert(reach_table->Lookup(PPointPair(loophead, source)));

            if (!body_table->Insert(PPointPair(loophead, source))) {
                body_list->PushBack(source);
                worklist.PushBack(source);
            }
        }
    }

    // this should only be called on loops that have actual backedges
    Assert(!worklist.Empty());

    while (!worklist.Empty()) {
        PPoint back = worklist.Back();
        worklist.PopBack();

        if (back == loophead)
            continue;

        const Vector<PEdge*> &incoming = cfg->GetIncomingEdges(back);
        for (size_t iind = 0; iind < incoming.Size(); iind++) {
            PEdge *edge = incoming[iind];
            PPoint source = edge->GetSource();

            if (reach_table->Lookup(PPointPair(loophead, source))) {
                if (!body_table->Insert(PPointPair(loophead, source))) {
                    body_list->PushBack(source);
                    worklist.PushBack(source);
                }
            }
            else if (entry_reach_table->Lookup(source)) {
                // the source is not reachable from the loophead.
                // this is an irreducible edge.
                irreducible_edges->PushBack(edge);
            }
        }
    }
}
TEST(Vector, PushBack) {
  Vector<int> v;
  v.PushBack(12345);
  EXPECT_FALSE(v.IsEmpty());
  EXPECT_EQ(1U, v.GetCount());
  EXPECT_EQ(12345, v[0]);
}
Example #11
0
void PrepassStage::OITInitPass(RenderingCamera * Camera, Spatial * spatial, RenderQueue* renderQueue, WorkQueue * Queue, Vector<OsEvent*>& Events) {
    RenderView * renderview = RenderView::Create();
    RenderViews.PushBack(renderview);
    renderview->Camera = Camera;
    renderview->Type = R_STAGE_OIT;
    renderview->Index = 0;
    renderview->Queue = renderQueue;
    renderview->Parameters.Clear();
    // set render target
    renderview->TargetCount = 0;
    renderview->Targets[0] = -1; // Context->GetRenderTarget("gPostBuffer");
    renderview->Depth = Depth;
    renderview->ClearDepth = 0;
    renderview->ClearTargets = 0;
    // 4. submit to workqueue
    int count = 1;
    while (count--) {
        CullingTask * task = CullingTask::Create();
        task->renderview = renderview;
        task->spatial = spatial;
        task->Context = Context;
        task->ObjectType = Node::TRANS;
        Queue->QueueTask(task);
    }
    Events.PushBack(renderview->Event);
}
Example #12
0
void PrepassStage::PrePass(RenderingCamera * Camera, Spatial * spatial, RenderQueue* renderQueue, WorkQueue * Queue, Vector<OsEvent*>& Events) {
    RenderView * renderview = RenderView::Create();
    RenderViews.PushBack(renderview);
    renderview->Camera = Camera;
    renderview->Depth = 0;
    renderview->Type = R_STAGE_PREPASSS;
    renderview->Index = 0;
    renderview->Queue = renderQueue;
    // set render target
    renderview->TargetCount = 4;
    renderview->Targets[0] = Targets[0];
    renderview->Targets[1] = Targets[1];
    renderview->Targets[2] = Targets[3];
    renderview->Targets[3] = Targets[4];
    renderview->Depth = Depth;
    renderview->Parameters.Clear();
    renderview->ClearDepth = 1;
    renderview->ClearTargets = 1;
    // 4. submit to workqueue
    int count = 1;
    while (count--) {
        CullingTask * task = CullingTask::Create();
        task->renderview = renderview;
        task->spatial = spatial;
        task->Context = Context;
        task->ObjectType = Node::RENDEROBJECT;
        Queue->QueueTask(task);
    }
    Events.PushBack(renderview->Event);
}
XdbInfo& GetDatabaseInfo(const uint8_t *name, bool do_create)
{
  Assert(!cleared_databases);
  String *name_str = String::Make((const char*)name);
  for (size_t dind = 0; dind < databases.Size(); dind++) {
    if (databases[dind].name == name_str) {
      XdbInfo &info = databases[dind];

      // create the database if we previously did a non-create access.
      if (do_create && !info.xdb->Exists()) {
        info.xdb->Create();
        if (info.xdb->HasError()) {
          logout << "ERROR: Corrupt database " << (const char*) name << endl;
          info.xdb->Truncate();
        }
      }

      return info;
    }
  }

  Xdb *xdb = new Xdb((const char*) name, do_create, false, false);
  if (xdb->HasError()) {
    logout << "ERROR: Corrupt database " << (const char*) name << endl;
    xdb->Truncate();
  }

  XdbInfo info;
  info.name = name_str;
  info.xdb = xdb;
  databases.PushBack(info);

  return databases.Back();
}
Example #14
0
    O3DGCErrorCode    LoadUIntAC(Vector<long> & data,
                                 const unsigned long M,
                                 const BinaryStream & bstream,
                                 unsigned long & iterator) 
    {
        unsigned long sizeSize = bstream.ReadUInt32Bin(iterator) - 12;
        unsigned long size     = bstream.ReadUInt32Bin(iterator);
        if (size == 0)
        {
            return O3DGC_OK;
        }
        long minValue   = bstream.ReadUInt32Bin(iterator);
        unsigned char * buffer = 0;
        bstream.GetBuffer(iterator, buffer);
        iterator += sizeSize;
        data.Allocate(size);
        Arithmetic_Codec acd;
        acd.set_buffer(sizeSize, buffer);
        acd.start_decoder();
        Adaptive_Data_Model mModelValues(M+1);
#ifdef DEBUG_VERBOSE
        printf("-----------\nsize %i\n", size);
        fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
        for(unsigned long i = 0; i < size; ++i)
        {
            data.PushBack(acd.decode(mModelValues)+minValue);
#ifdef DEBUG_VERBOSE
            printf("%i\t%i\n", i, data[i]);
            fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
        }
        return O3DGC_OK;
    }
Example #15
0
    O3DGCErrorCode    LoadBinAC(Vector<long> & data,
                                const BinaryStream & bstream,
                                unsigned long & iterator) 
    {
        size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 8;
        size_t size     = bstream.ReadUInt32Bin(iterator);
        if (size == 0)
        {
            return O3DGC_OK;
        }
        unsigned char * buffer = 0;
        bstream.GetBuffer(iterator, buffer);
        iterator += sizeSize;
        data.Allocate(size);
        Arithmetic_Codec acd;
        acd.set_buffer(sizeSize, buffer);
        acd.start_decoder();
        Adaptive_Bit_Model bModel;
#ifdef DEBUG_VERBOSE
        printf("-----------\nsize %i\n", size);
        fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
        for(size_t i = 0; i < size; ++i)
        {
            data.PushBack(acd.decode(bModel));
#ifdef DEBUG_VERBOSE
            printf("%i\t%i\n", i, data[i]);
            fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
        }
        return O3DGC_OK;
    }
void handle_connect(int sockfd, short, void*)
{
  logout << "Received connection." << endl << flush;

  int newfd = accept(sockfd, NULL, 0);
  if (newfd == -1) {
    logout << "ERROR: accept() failure: " << errno << endl;
    return;
  }

  ConnectData *cdata = new ConnectData();
  connections.PushBack(cdata);

  cdata->live = true;
  cdata->fd = newfd;
  event_set(&cdata->ev, newfd, EV_READ | EV_PERSIST,
            handle_event, (void*) (connections.Size() - 1));

  int ret = event_add(&cdata->ev, NULL);
  if (ret == -1) {
    logout << "ERROR: event_add() failure: " << errno << endl;
    delete cdata;
    return;
  }
}
Example #17
0
Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch )
{
  unsigned int numVertex = numOfPatch*4u;
  std::vector<Vertex> vertexData;
  vertexData.reserve( numVertex );

  unsigned int numIndex = numOfPatch*6u;
  Vector<unsigned int> indexData;
  indexData.Reserve( numIndex );

  for(unsigned int i = 0; i < numOfPatch; i++)
  {
    float curSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y, mRandomSeed);

    float index = static_cast<float>( i );
    vertexData.push_back( Vertex( index, Vector2(0.f,0.f),         Vector2(0.f,0.f) ) );
    vertexData.push_back( Vertex( index, Vector2(0.f,curSize),     Vector2(0.f,1.f)  ) );
    vertexData.push_back( Vertex( index, Vector2(curSize,curSize), Vector2(1.f,1.f)  ) );
    vertexData.push_back( Vertex( index, Vector2(curSize,0.f),     Vector2(1.f,0.f)  ) );

    unsigned int idx = index * 4;
    indexData.PushBack( idx );
    indexData.PushBack( idx+1 );
    indexData.PushBack( idx+2 );
    indexData.PushBack( idx );
    indexData.PushBack( idx+2 );
    indexData.PushBack( idx+3 );
  }

  Property::Map vertexFormat;
  vertexFormat["aIndex"] = Property::FLOAT;
  vertexFormat["aPosition"] = Property::VECTOR2;
  vertexFormat["aTexCoord"] = Property::VECTOR2;
  PropertyBuffer vertices = PropertyBuffer::New( vertexFormat, numVertex  );
  vertices.SetData( &vertexData[0] );

  Property::Map indexFormat;
  indexFormat["indices"] = Property::INTEGER;
  PropertyBuffer indices = PropertyBuffer::New( indexFormat, numIndex  );
  indices.SetData( &indexData[0] );

  Geometry geometry = Geometry::New();
  geometry.AddVertexBuffer( vertices );
  geometry.SetIndexBuffer( indices );

  return geometry;
}
TEST(Vector, PushBack2) {
  const int kMaxCount = 500;
  Vector<int> v;
  for (int n = 0; n < kMaxCount; ++n)
    v.PushBack(n * 100);

  EXPECT_FALSE(v.IsEmpty());
  EXPECT_EQ(static_cast<size_t>(kMaxCount), v.GetCount());
}
int UtcDaliVectorIntCopy(void)
{
  tet_infoline("Testing Dali::Vector<int>::Copy");

  Vector< int > intvector;
  DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION );

  intvector.PushBack( 99 );
  intvector.PushBack( 11 );
  intvector.PushBack( 34 );

  // copy construct
  Vector< int > intvector2( intvector );

  DALI_TEST_EQUALS( intvector2.Count(), intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( intvector2.Capacity(), intvector.Capacity(), TEST_LOCATION );
  DALI_TEST_EQUALS( intvector2[ 0 ], intvector[ 0 ], TEST_LOCATION );
  DALI_TEST_EQUALS( intvector2[ 1 ], intvector[ 1 ], TEST_LOCATION );
  DALI_TEST_EQUALS( intvector2[ 2 ], intvector[ 2 ], TEST_LOCATION );

  // assign
  Vector< int > intvector3;
  DALI_TEST_EQUALS( ZERO, intvector3.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, intvector3.Capacity(), TEST_LOCATION );
  intvector2 = intvector3;
  DALI_TEST_EQUALS( intvector2.Count(), intvector3.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( intvector2.Capacity(), intvector3.Capacity(), TEST_LOCATION );

  // copy empty
  Vector< int > intvector4;
  intvector4.Reserve( 100 );
  DALI_TEST_EQUALS( ZERO, intvector4.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(100), intvector4.Capacity(), TEST_LOCATION );
  intvector3 = intvector4;
  DALI_TEST_EQUALS( ZERO, intvector3.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(100), intvector3.Capacity(), TEST_LOCATION );

  // self copy
  intvector4 = intvector4;
  DALI_TEST_EQUALS( ZERO, intvector4.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(100), intvector4.Capacity(), TEST_LOCATION );
  END_TEST;
}
int UtcDaliVectorIntSwap(void)
{
  tet_infoline("Testing Dali::Vector<int>::Swap");

  Vector< int > intvector;
  DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION );

  intvector.PushBack( 11 );
  intvector.PushBack( 22 );
  intvector.PushBack( 33 );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(3), intvector.Count(), TEST_LOCATION );

  Vector< int > intvector2;
  DALI_TEST_EQUALS( ZERO, intvector2.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, intvector2.Capacity(), TEST_LOCATION );

  intvector2.Swap( intvector );
  DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(3), intvector2.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( 11, intvector2[ 0 ], TEST_LOCATION );
  DALI_TEST_EQUALS( 22, intvector2[ 1 ], TEST_LOCATION );
  DALI_TEST_EQUALS( 33, intvector2[ 2 ], TEST_LOCATION );

  intvector.PushBack( 99 );
  intvector.PushBack( 88 );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(2), intvector.Count(), TEST_LOCATION );

  intvector.Swap( intvector2 );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(2), intvector2.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( 99, intvector2[ 0 ], TEST_LOCATION );
  DALI_TEST_EQUALS( 88, intvector2[ 1 ], TEST_LOCATION );
  DALI_TEST_EQUALS( static_cast<Dali::VectorBase::SizeType>(3), intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( 11, intvector[ 0 ], TEST_LOCATION );
  DALI_TEST_EQUALS( 22, intvector[ 1 ], TEST_LOCATION );
  DALI_TEST_EQUALS( 33, intvector[ 2 ], TEST_LOCATION );

  Vector< int > empty;
  intvector.Swap( empty );
  DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION );
  END_TEST;
}
TEST(Vector, IndexOf) {
  const int kMaxCount = 500;
  Vector<int> v;
  for (int n = 0; n < kMaxCount; ++n)
    v.PushBack(n * 100);

  for (int n = 0; n < kMaxCount; ++n) {
    TEST_TEXT << "Checking v.IndexOf(" << n * 100 << ")";
    EXPECT_EQ(n, v.IndexOf(n * 100));
  }
}
TEST(Vector, At) {
  const int kMaxCount = 500;
  Vector<int> v;
  for (int n = 0; n < kMaxCount; ++n)
    v.PushBack(n * 100);

  for (int n = 0; n < kMaxCount; ++n) {
    TEST_TEXT << "Checking v[" << n << "]";
    EXPECT_EQ(n * 100, v[n]);
  }
}
Example #23
0
// get the set of points reachable from loophead over paths
// that do not go through a backedge. if loophead itself is
// reachable, it is irreducible and those new edges to it are added
// as backedges. return value is true iff the loop is irreducible.
bool GetLoopReachable(BlockCFG *cfg, PPoint loophead)
{
    // worklist items are points in reach_table whose outgoing edges
    // have not been examined
    Vector<PPoint> worklist;

    if (!entry_reach_table->Lookup(loophead))
        return false;

    reach_table->Insert(PPointPair(loophead, loophead));
    worklist.PushBack(loophead);

    bool found_irreducible = false;

    while (!worklist.Empty()) {
        PPoint back = worklist.Back();
        worklist.PopBack();

        const Vector<PEdge*>& outgoing = cfg->GetOutgoingEdges(back);
        for (size_t oind = 0; oind < outgoing.Size(); oind++) {
            PEdge *edge = outgoing[oind];
            PPoint next = edge->GetTarget();

            if (backedge_table->Lookup(edge))
                continue;

            if (next == loophead) {
                // we're in an irreducible loop. add the new edge to backedge_table.
                backedge_table->Insert(edge);
                found_irreducible = true;
                continue;
            }

            if (!reach_table->Insert(PPointPair(loophead, next)))
                worklist.PushBack(next);
        }
    }

    return found_irreducible;
}
int UtcDaliVectorVector3P(void)
{
  tet_infoline("Testing Dali::Vector< Vector3 >");

  Vector< Vector3 > classvector;
  DALI_TEST_EQUALS( ZERO, classvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, classvector.Capacity(), TEST_LOCATION );

  classvector.PushBack( Vector3() );

  DALI_TEST_EQUALS( 1u, classvector.Count(), TEST_LOCATION );
  DALI_TEST_GREATER( classvector.Capacity(), ZERO, TEST_LOCATION );

  classvector.PushBack( Vector3( 0.1f, 0.2f, 0.3f ) );

  DALI_TEST_EQUALS( 2u, classvector.Count(), TEST_LOCATION );

  DALI_TEST_EQUALS( Vector3(), classvector[ 0 ], TEST_LOCATION );
  DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), classvector[ 1 ], TEST_LOCATION );

  tet_result(TET_PASS); // for now
  END_TEST;
}
Example #25
0
 O3DGCErrorCode    LoadIntData(Vector<long> & data,
                               const BinaryStream & bstream,
                               unsigned long & iterator) 
 {
     bstream.ReadUInt32ASCII(iterator);
     const unsigned long size = bstream.ReadUInt32ASCII(iterator);
     data.Allocate(size);
     data.Clear();
     for(size_t i = 0; i < size; ++i)
     {
         data.PushBack(bstream.ReadIntASCII(iterator));
     }
     return O3DGC_OK;
 }
int UtcDaliVectorMatrixP(void)
{
  tet_infoline("Testing Dali::Vector< Matrix >");

  Vector< Matrix > classvector;
  DALI_TEST_EQUALS( ZERO, classvector.Count(), TEST_LOCATION );
  DALI_TEST_EQUALS( ZERO, classvector.Capacity(), TEST_LOCATION );

  classvector.PushBack( Matrix() );

  DALI_TEST_EQUALS( 1u, classvector.Count(), TEST_LOCATION );
  DALI_TEST_GREATER( classvector.Capacity(), ZERO, TEST_LOCATION );

  classvector.PushBack( Matrix::IDENTITY );

  DALI_TEST_EQUALS( 2u, classvector.Count(), TEST_LOCATION );

  DALI_TEST_EQUALS( Matrix(), classvector[ 0 ], TEST_LOCATION );
  DALI_TEST_EQUALS( Matrix::IDENTITY, classvector[ 1 ], TEST_LOCATION );

  tet_result(TET_PASS); // for now
  END_TEST;
}
    void ProximityComponent::UpdateContainment(Vector<uint64_t> &sceneNodesEntered, Vector<uint64_t> &sceneNodesLeft)
    {
        SortedVector<uint64_t> sceneNodesLeaving(this->sceneNodesInsideVolume);

        ProximityComponent::Iterator i(*this);
        while (i)
        {
            if (i.otherNode != &this->GetNode())
            {
                assert(i.otherNode != nullptr);
                {
                    auto otherNodeID = i.otherNode->GetID();

                    if (!this->sceneNodesInsideVolume.Exists(otherNodeID))
                    {
                        this->sceneNodesInsideVolume.Insert(otherNodeID);
                        sceneNodesEntered.PushBack(otherNodeID);
                    }
                    else
                    {
                        sceneNodesLeaving.RemoveFirstOccuranceOf(otherNodeID);
                    }
                }
            }

            ++i;
        }


        // At this point we'll have a list of nodes that have left the volume. We need to copies these over to 'sceneNodesLeft'.
        for (size_t j = 0; j < sceneNodesLeaving.count; ++j)
        {
            sceneNodesLeft.PushBack(sceneNodesLeaving[j]);
            this->sceneNodesInsideVolume.RemoveFirstOccuranceOf(sceneNodesLeaving[j]);
        }
    }
TEST(Vector, PopFirst) {
  const int kMaxCount = 500;
  Vector<int> v;
  for (int n = 0; n < kMaxCount; ++n)
    v.PushBack(n * 100);

  for (int n = 0; n < kMaxCount; ++n) {
    int first = v.PopFirst();
    TEST_TEXT << "Checking " << n << "-th PopFirst()";
    EXPECT_EQ(n * 100, first);
    EXPECT_EQ(kMaxCount - 1 - n, v.GetCount());
  }
  EXPECT_EQ(0u, v.GetCount());
  EXPECT_TRUE(v.IsEmpty());
}
Example #29
0
    O3DGCErrorCode    LoadIntACEGC(Vector<long> & data,
                                   const unsigned long M,
                                   const BinaryStream & bstream,
                                   unsigned long & iterator) 
    {
        size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 12;
        size_t size     = bstream.ReadUInt32Bin(iterator);
        if (size == 0)
        {
            return O3DGC_OK;
        }
        long minValue   = bstream.ReadUInt32Bin(iterator) - O3DGC_MAX_LONG;
        unsigned char * buffer = 0;
        bstream.GetBuffer(iterator, buffer);
        iterator += sizeSize;
        data.Allocate(size);
        Arithmetic_Codec acd;
        acd.set_buffer(sizeSize, buffer);
        acd.start_decoder();
        Adaptive_Data_Model mModelValues(M+2);
        Static_Bit_Model bModel0;
        Adaptive_Bit_Model bModel1;
        unsigned long value;

#ifdef DEBUG_VERBOSE
        printf("-----------\nsize %i\n", size);
        fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
        for(size_t i = 0; i < size; ++i)
        {
            value = acd.decode(mModelValues);
            if ( value == M)
            {
                value += acd.ExpGolombDecode(0, bModel0, bModel1);
            }
            data.PushBack(value + minValue);
#ifdef DEBUG_VERBOSE
            printf("%i\t%i\n", i, data[i]);
            fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
        }
#ifdef DEBUG_VERBOSE
        fflush(g_fileDebugTF);
#endif //DEBUG_VERBOSE
        return O3DGC_OK;
    }
TEST(Vector, RemoveAt) {
  const int kMaxCount = 500;

  for (size_t k = 0; k < kMaxCount; ++k) {
    Vector<int> v;
    for (int n = 0; n < kMaxCount; ++n)
      v.PushBack(n * 100);

    v.RemoveAt(k);

    EXPECT_EQ(kMaxCount - 1, v.GetCount());
    for (int n = 0; n < kMaxCount - 1; ++n) {
      TEST_TEXT << "Checking v[" << n << "]";
      int expected = (n < k) ? (n * 100) : ((n + 1) * 100);
      EXPECT_EQ(expected, v[n]);
    }
  }
}