本文整理汇总了C++中FixedArray类的典型用法代码示例。如果您正苦于以下问题:C++ FixedArray类的具体用法?C++ FixedArray怎么用?C++ FixedArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FixedArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __py_count
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_count(PyObject* self, PyObject* args, PyObject* kwargs)
{
FixedArray* ary = static_cast<FixedArray*>(self);
PyObject* pyItem = PyTuple_GetItem(args, 0);
int count = 0, cur;
for (uint32 i = 0; (cur = ary->findFrom(i, &*pyItem)) >= 0; i = cur + 1)
++count;
return PyLong_FromLong(count);
}
示例2: integerToSixCharacterHashString
void CodeBlockHash::dump(PrintStream& out) const
{
FixedArray<char, 7> buffer = integerToSixCharacterHashString(m_hash);
#if !ASSERT_DISABLED
CodeBlockHash recompute(buffer.data());
ASSERT(recompute == *this);
#endif // !ASSERT_DISABLED
out.print(buffer.data());
}
示例3: TEST
TEST(Array, ConstructionTest)
{
ConstructionTest::Reset();
FixedArray<20, ConstructionTest> array;
EXPECT_EQ(0, ConstructionTest::Count());
for(int i = 0; i<10; i++)
{
array.push_back( );
EXPECT_EQ(i+1, ConstructionTest::Count());
}
}
示例4: PyTuple_GetItem
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_index(PyObject* self, PyObject* args, PyObject* kwargs)
{
FixedArray* ary = static_cast<FixedArray*>(self);
PyObject* pyItem = PyTuple_GetItem(args, 0);
int index = ary->findFrom(0, &*pyItem);
if (index == -1)
{
PyErr_SetString(PyExc_ValueError, "FixedArray::index: value not found");
return NULL;
}
return PyLong_FromLong(index);
}
示例5: NODE_IMPLEMENTATION
NODE_IMPLEMENTATION(transpose_mXX, Pointer)
{
FixedArray* Aarray = NODE_ARG_OBJECT(0, FixedArray);
const Class* mtype = static_cast<const Class*>(Aarray->type());
FixedArray* Carray = static_cast<FixedArray*>(ClassInstance::allocate(mtype));
EigenMatXf A(Aarray->data<float>(), Aarray->size(0), Aarray->size(1));
EigenMatXf C(Carray->data<float>(), Aarray->size(0), Aarray->size(1));
C = A.transpose();
NODE_RETURN(Carray);
}
示例6: startup
virtual kernel::ApplicationResult startup( kernel::Params & params )
{
#if 0
printf( "Memory Test: \n" );
Test * a = CREATE(Test);
std::vector<int, GeminiAllocator<int> > int_vector;
int_vector.push_back( 30 );
int_vector.push_back( 16 );
int_vector.push_back( 31 );
typedef std::map<int, int, std::less<int>, GeminiAllocator<int> > MyMap;
MyMap int_map;
int_map.insert( MyMap::value_type( 30, 17 ) );
int_map.insert( MyMap::value_type( 16, 100) );
int_map.insert( MyMap::value_type( 300, 2 ) );
// Test FixedArray - which should cause derived destructors
// to be called as well as the BaseObject's destructors.
FixedArray<BaseObject> objects;
objects.allocate(3);
for( size_t i = 0; i < 3; ++i )
{
objects[i] = CREATE(DerivedObject);
objects[i]->type = i+4;
}
objects.purge();#
// added z-modifer to satisfy Xcode, C99 addition, we'll see who doesn't support it :)
printf( "totalAllocations: %zu, totalBytes: %zu\n", memory::allocator().total_allocations(), memory::allocator().total_bytes() );
printf( "activeAllocations: %zu, activeBytes: %zu\n", memory::allocator().active_allocations(), memory::allocator().active_bytes() );
DESTROY(Test, a);
printf( "activeAllocations: %zu, activeBytes: %zu\n", memory::allocator().active_allocations(), memory::allocator().active_bytes() );
#endif
PooledObject * p = new DerivedPoolObject();
delete p;
return kernel::Application_NoWindow;
}
示例7: DrawFace
void CSceneNodeAABB::DrawFace(const FixedArray<vector3,4> &r,unsigned int divA,unsigned int divB) const{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_AUTO_NORMAL);
glMap2f( GL_MAP2_VERTEX_3,0.0f,1.0f,3,2,0.0f,1.0f,6,2,(GLfloat*)r.PtrBegin());
GLenum err(glGetError());
glMapGrid2f(divA,0,1,divB,0,1);
err = glGetError();
glEvalMesh2(GL_FILL,0,divA,0,divB);
err = glGetError();
glPopAttrib();
}
示例8: PyTuple_Size
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__unpickle__(PyObject* self, PyObject* args)
{
Py_ssize_t size = PyTuple_Size(args);
if(size != 2)
{
ERROR_MSG("FixedArray::__unpickle__: args is wrong! (size != 2)");
S_Return;
}
PyObject* pyDatatypeUID = PyTuple_GET_ITEM(args, 0);
DATATYPE_UID uid = (DATATYPE_UID)PyLong_AsUnsignedLong(pyDatatypeUID);
PyObject* pyList = PyTuple_GET_ITEM(args, 1);
if(pyList == NULL)
{
ERROR_MSG("FixedArray::__unpickle__: args is wrong!");
S_Return;
}
FixedArray* pFixedArray = new FixedArray(DataTypes::getDataType(uid));
pFixedArray->initialize(pyList);
return pFixedArray;
}
示例9: getFovRad
//---------------------------------------------------------------------------//
FixedArray<glm::vec3, 8u> CameraComponent::getWSfrustumCorners(float aViewportAspectRatio)
{
//calculate frustum corner coordinates
float fFov2 = getFovRad() * 0.5f;
float tanFov2 = glm::tan( fFov2 );
float h2Far = tanFov2 * m_fFar;
float h2Near = tanFov2 * m_fNear;
float hFar = 2.0f * h2Far;
float hNear = 2.0f * h2Near;
Rendering::RenderOutput* renderer = Fancy::GetCurrentRenderOutput();
float aspect = aViewportAspectRatio;
float w2Far = ( hFar * aspect ) / 2.0f;
float w2Near = ( hNear * aspect ) / 2.0f;
glm::vec3 v3Corners[ 8 ];
v3Corners[ 0 ] = glm::vec3( -1.0f * w2Near, -1.0f * h2Near, -m_fNear ); //l,b,n
v3Corners[ 1 ] = glm::vec3( 1.0f * w2Near, -1.0f * h2Near, -m_fNear ); //r,b,n
v3Corners[ 2 ] = glm::vec3( 1.0f * w2Near, 1.0f * h2Near, -m_fNear ); //r,t,n
v3Corners[ 3 ] = glm::vec3( -1.0f * w2Near, 1.0f * h2Near, -m_fNear ); //l,t,n
v3Corners[ 4 ] = glm::vec3( -1.0f * w2Far, -1.0f * h2Far, -m_fFar ); //l,b,n
v3Corners[ 5 ] = glm::vec3( 1.0f * w2Far, -1.0f * h2Far, -m_fFar ); //r,b,n
v3Corners[ 6 ] = glm::vec3( 1.0f * w2Far, 1.0f * h2Far, -m_fFar ); //r,t,n
v3Corners[ 7 ] = glm::vec3( -1.0f * w2Far, 1.0f * h2Far, -m_fFar ); //l,t,n
FixedArray<glm::vec3, 8u> vReturnCorners;
vReturnCorners.resize(8);
//transform each corner into WS
for( int i = 0; i < 8; ++i )
{
vReturnCorners[i] = glm::vec3( m_matViewInv * glm::vec4( v3Corners[ i ], 1.0f ) );
}
return vReturnCorners;
}
示例10: TEST
TEST(FixedArray, trivial){
FixedArray array;
EXPECT_EQ(0, array.num());
EXPECT_EQ(0, array.len());
for (uint64_t i = 0; i < 10; ++i){
array.PushBack(i);
}
for (uint64_t i = 10; ; --i){
array.PushBack(i);
if (i == 0) break;
}
for (uint64_t i = 0; i < 10; ++i){
EXPECT_EQ(i, array.Get(i));
}
for (uint64_t i = 0; i < 10; ++i){
EXPECT_EQ(10 - i, array.Get(i+10));
}
}
示例11: lexicographical_compare
bool operator<(const FixedArray<N, T>& other) const
{
return std::lexicographical_compare(begin(), end(),
other.begin(), other.end());
}
示例12: __py_append
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_append(PyObject* self, PyObject* args, PyObject* kwargs)
{
FixedArray* ary = static_cast<FixedArray*>(self);
uint32 seq_size = ary->length();
return PyBool_FromLong(seq_ass_slice(self, seq_size, seq_size, &*args) == 0);
}
示例13: qsort
OpcodeStats::~OpcodeStats()
{
long long totalInstructions = 0;
for (int i = 0; i < numOpcodeIDs; ++i)
totalInstructions += opcodeCounts[i];
long long totalInstructionPairs = 0;
for (int i = 0; i < numOpcodeIDs; ++i)
for (int j = 0; j < numOpcodeIDs; ++j)
totalInstructionPairs += opcodePairCounts[i][j];
FixedArray<int, numOpcodeIDs> sortedIndices;
for (int i = 0; i < numOpcodeIDs; ++i)
sortedIndices[i] = i;
qsort(sortedIndices.data(), numOpcodeIDs, sizeof(int), compareOpcodeIndices);
pair<int, int> sortedPairIndices[numOpcodeIDs * numOpcodeIDs];
pair<int, int>* currentPairIndex = sortedPairIndices;
for (int i = 0; i < numOpcodeIDs; ++i)
for (int j = 0; j < numOpcodeIDs; ++j)
*(currentPairIndex++) = make_pair(i, j);
qsort(sortedPairIndices, numOpcodeIDs * numOpcodeIDs, sizeof(pair<int, int>), compareOpcodePairIndices);
printf("\nExecuted opcode statistics\n");
printf("Total instructions executed: %lld\n\n", totalInstructions);
printf("All opcodes by frequency:\n\n");
for (int i = 0; i < numOpcodeIDs; ++i) {
int index = sortedIndices[i];
printf("%s:%s %lld - %.2f%%\n", opcodeNames[index], padOpcodeName((OpcodeID)index, 28), opcodeCounts[index], ((double) opcodeCounts[index]) / ((double) totalInstructions) * 100.0);
}
printf("\n");
printf("2-opcode sequences by frequency: %lld\n\n", totalInstructions);
for (int i = 0; i < numOpcodeIDs * numOpcodeIDs; ++i) {
pair<int, int> indexPair = sortedPairIndices[i];
long long count = opcodePairCounts[indexPair.first][indexPair.second];
if (!count)
break;
printf("%s%s %s:%s %lld %.2f%%\n", opcodeNames[indexPair.first], padOpcodeName((OpcodeID)indexPair.first, 28), opcodeNames[indexPair.second], padOpcodeName((OpcodeID)indexPair.second, 28), count, ((double) count) / ((double) totalInstructionPairs) * 100.0);
}
printf("\n");
printf("Most common opcodes and sequences:\n");
for (int i = 0; i < numOpcodeIDs; ++i) {
int index = sortedIndices[i];
long long opcodeCount = opcodeCounts[index];
double opcodeProportion = ((double) opcodeCount) / ((double) totalInstructions);
if (opcodeProportion < 0.0001)
break;
printf("\n%s:%s %lld - %.2f%%\n", opcodeNames[index], padOpcodeName((OpcodeID)index, 28), opcodeCount, opcodeProportion * 100.0);
for (int j = 0; j < numOpcodeIDs * numOpcodeIDs; ++j) {
pair<int, int> indexPair = sortedPairIndices[j];
long long pairCount = opcodePairCounts[indexPair.first][indexPair.second];
double pairProportion = ((double) pairCount) / ((double) totalInstructionPairs);
if (!pairCount || pairProportion < 0.0001 || pairProportion < opcodeProportion / 100)
break;
if (indexPair.first != index && indexPair.second != index)
continue;
printf(" %s%s %s:%s %lld - %.2f%%\n", opcodeNames[indexPair.first], padOpcodeName((OpcodeID)indexPair.first, 28), opcodeNames[indexPair.second], padOpcodeName((OpcodeID)indexPair.second, 28), pairCount, pairProportion * 100.0);
}
}
printf("\n");
}
示例14: LoadTextureCube
void TextureLoader::LoadTextureCube(const char * filenames[6], DescTextureCube & texture, FixedArray<unsigned char> & texture_data)
{
int texture_width = 0;
int texture_height = 0;
int texture_channels = 0;
unsigned int pixel_format;
unsigned int total_face_bytes = 0;
unsigned int dest_offset = 0;
for (unsigned int i = 0; i < 6; ++i)
{
std::string file(filenames[i]);
size_t pos = file.find('.');
if (pos == std::string::npos)
{
throw Exception("No file extension found in filename.");
}
pos += 1;
std::string extension = file.substr(pos, file.length()-pos);
if (extension.compare("png") == 0 ||
extension.compare("jpg") == 0 ||
extension.compare("jpeg") == 0 ||
extension.compare("bmp") == 0 ||
extension.compare("tga") == 0 ||
extension.compare("dds") == 0 ||
extension.compare("hdr") == 0 ||
extension.compare("psd") == 0)
{
int width, height, channels;
unsigned char *data = SOIL_load_image
(
filenames[i],
&width, &height, &channels,
SOIL_LOAD_RGBA
);
unsigned int format;
/*
switch(channels)
{
case 1:
throw Exception("Format not recognized or supported.");
break;
case 2:
throw Exception("Format not recognized or supported.");
break;
case 3:
throw Exception("Format not recognized or supported.");
break;
case 4:
format = PF_32_R8G8B8A8;
break;
default:
throw Exception("Format not recognized or supported.");
break;
}
*/
format = PF_32_R8G8B8A8;
if (texture_width == 0 && texture_height == 0)
{
texture_width = width;
texture_height = height;
texture_channels = channels;
pixel_format = format;
total_face_bytes = texture_width*texture_height*4;
texture_data.Set(total_face_bytes * 6);
//texture.BindFlags = BIND_SHADER_RESOURCE;
texture.Format = format;
texture.Width = width;
texture.Height = height;
//texture.Usage = TEXTURE_USAGE_STATIC;
//texture.MipLevels = 1;
}
else
{
if (texture_width != width)
{
throw Exception("Different Widths In Cube Map.");
}
if (texture_height != height)
{
throw Exception("Different Heights In Cube Map.");
}
if (texture_channels != channels)
{
throw Exception("Different Channels In Cube Map.");
}
if (pixel_format != format)
{
throw Exception("Different Format In Cube Map.");
}
}
memcpy(texture_data.GetData() + dest_offset, data, total_face_bytes);
texture.InitialData[i] = texture_data.GetData() + dest_offset;
dest_offset += total_face_bytes;
free(data);
//.........这里部分代码省略.........
示例15: file
void TextureLoader::LoadTexture2D(const char * filename, DescTexture2D & texture, FixedArray<unsigned char> & texture_data)
{
std::string file(filename);
size_t pos = file.find('.');
CONDITIONAL_EXCEPTION(pos == std::string::npos, "No file extension found in filename.");
pos += 1;
std::string extension = file.substr(pos, file.length()-pos);
if (extension.compare("png") == 0 ||
extension.compare("jpg") == 0 ||
extension.compare("jpeg") == 0 ||
extension.compare("bmp") == 0 ||
extension.compare("tga") == 0 ||
extension.compare("dds") == 0 ||
extension.compare("hdr") == 0 ||
extension.compare("psd") == 0)
{
int width, height, channels;
unsigned char *data = SOIL_load_image
(
filename,
&width, &height, &channels,
SOIL_LOAD_RGBA
);
unsigned int format;
/*
switch(channels)
{
case 1:
throw Exception("Format not recognized or supported.");
break;
case 2:
throw Exception("Format not recognized or supported.");
break;
case 3:
throw Exception("Format not recognized or supported.");
break;
case 4:
format = PF_32_R8G8B8A8;
break;
default:
throw Exception("Format not recognized or supported.");
break;
}
*/
format = PF_32_R8G8B8A8;
unsigned int texture_size = width*height*4;
texture_data.Set(texture_size);
memcpy(texture_data.GetData(), data, texture_size);
//texture.BindFlags = BIND_SHADER_RESOURCE;
texture.Format = format;
texture.Width = width;
texture.Height = height;
//texture.Usage = TEXTURE_USAGE_STATIC;
//texture.MipLevels = 1;
texture.InitialData = texture_data.GetData();
free(data);
}
else
{
throw Exception("File extension not supported.");
}
}