本文整理汇总了C++中Insert函数的典型用法代码示例。如果您正苦于以下问题:C++ Insert函数的具体用法?C++ Insert怎么用?C++ Insert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Insert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Insert
// Insert the Value into its proper place in the binary search tree
void BST::Insert(int Value)
{ Insert(Root, Value); }
示例2: Insert
void Insert(Type key)
{
Insert(root , key);
}
示例3: Emplace
////////////////////////////////////////////////////////////////////////////////
// Construct and insert an account //
// //
// Parameters: //
// id: the ID //
// plaintext: the plain password //
// //
// Return Value: //
// true if insert succeeded, false if the ID already exists //
////////////////////////////////////////////////////////////////////////////////
bool AccountMap::Emplace( const ID& id, const Plaintext& plaintext ) {
if(Insert(id, plaintext)) {
return true;
}
return false;
}
示例4: Insert
void Tree::Insert(int data)
{
Insert(Root, data);
}
示例5: PushBack
void PushBack(const T& x)
{
Insert(End(), x);
}
示例6: Compute
void Compute(int i)
{
int x1,x2,y1,y2;
double edg1,edg2;
x1=v[i].sx-tx;
y1=v[i].sy-ty;
x2=v[i].ex-tx;
y2=v[i].ey-ty;
if(y1==0&&y2==0)
return;
if(y1==0)
{
if(x1>0)
{
if(y2>0)
{
temp.sx=v[i].sx;
temp.sy=v[i].sy;
temp.ex=v[i].ex;
temp.ey=v[i].ey;
temp.edgs=0;
temp.edge=atan2(y2,x2);
}
else
{
temp.sx=v[i].ex;
temp.sy=v[i].ey;
temp.ex=v[i].sx;
temp.ey=v[i].sy;
temp.edgs=atan2(y2,x2);
temp.edge=0;
}
}
else
{
if(y2>0)
{
temp.sx=v[i].ex;
temp.sy=v[i].ey;
temp.ex=v[i].sx;
temp.ey=v[i].sy;
temp.edgs=atan2(y2,x2);
temp.edge=3.141592654;
}
else
{
temp.sx=v[i].sx;
temp.sy=v[i].sy;
temp.ex=v[i].ex;
temp.ey=v[i].ey;
temp.edgs=-3.141592654;
temp.edge=atan2(y2,x2);
}
}
Insert();
}
else if(y2==0)
{
if(x2>0)
{
if(y1>0)
{
temp.sx=v[i].ex;
temp.sy=v[i].ey;
temp.ex=v[i].sx;
temp.ey=v[i].sy;
temp.edgs=0;
temp.edge=atan2(y1,x1);
}
else
{
temp.sx=v[i].sx;
temp.sy=v[i].sy;
temp.ex=v[i].ex;
temp.ey=v[i].ey;
temp.edgs=atan2(y1,x1);
temp.edge=0;
}
}
else
{
if(y1>0)
{
temp.sx=v[i].sx;
temp.sy=v[i].sy;
temp.ex=v[i].ex;
temp.ey=v[i].ey;
temp.edgs=atan2(y1,x1);
temp.edge=3.141592654;
}
else
{
temp.sx=v[i].ex;
temp.sy=v[i].ey;
temp.ex=v[i].sx;
temp.ey=v[i].sy;
temp.edgs=-3.141592654;
temp.edge=atan2(y1,x1);
}
}
//.........这里部分代码省略.........
示例7: Remove
void wxGISMenu::MoveCommandRight(size_t nIndex)
{
wxMenuItem *pMenuItem = Remove(FindItemByPosition(nIndex));
Insert(nIndex + 1, pMenuItem);
wxGISCommandBar::MoveCommandRight(nIndex);
}
示例8: TEXT
Mesh* Mesh::CreateFromFBX(RenderSystem* pRenderSys, tstring const& filename)
{
try
{
tstring path = Core::GetInstance()->GetAssetsDir() + TEXT("/Models/") + filename;
const aiScene* scene = aiImportFile(wstr2str(path).c_str(),
aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_ConvertToLeftHanded | aiProcess_TransformUVCoords);
Float3 min, max;
if (scene == nullptr || scene->mNumMeshes == 0)
throw std::exception("No Mesh in this file");
Mesh* ret = new Mesh();
for (uint32 meshIndex = 0; meshIndex < scene->mNumMeshes; ++meshIndex)
{
MeshPart* part = ret->CreatePart();
aiMesh* pAiPart = scene->mMeshes[meshIndex];
int32 numVertices = pAiPart->mNumVertices;
int32 numFaces = pAiPart->mNumFaces;
int32 numUVChannels = scene->mMeshes[meshIndex]->GetNumUVChannels();
if (!pAiPart->HasFaces()
|| !pAiPart->HasNormals()
|| !pAiPart->HasPositions()
|| !pAiPart->HasTextureCoords(0)
|| !pAiPart->HasTangentsAndBitangents())
{
ret->RemovePart(part);
continue;
};
min = Float3((float*)&(pAiPart->mVertices[0]));
max = Float3((float*)&(pAiPart->mVertices[0]));
part->m_pInputLayout.reset(new InputLayout{
{ VertexElemType::Float3, ElemSemantic::Position, 0, 0, ElementClass::PerVertex, 0 },
{ VertexElemType::Float3, ElemSemantic::Normal, 0, 0, ElementClass::PerVertex, 0 },
{ VertexElemType::Float3, ElemSemantic::Tangent, 0, 0, ElementClass::PerVertex, 0 },
});
auto layout = part->m_pInputLayout;
for (int32 i = 0; i < numUVChannels; ++i)
layout->Insert(layout->End(),
{ VertexElemType::Float2, ElemSemantic::TexCoord, (uint32)i, 0, ElementClass::PerVertex, 0 });
uint32 stride = layout->GetVertexStride(0);
byte* vertices = new byte[stride * numVertices];
uint16* indices = new uint16[3 * numFaces];
auto elemPosition = layout->Begin();
auto elemNormal = elemPosition + 1;
auto elemTangent = elemNormal + 1;
#define Get(V,i,stride,offset) (V + stride * i + offset)
for (int32 i = 0; i < numVertices; ++i)
{
*(Float3*)Get(vertices, i, stride, elemPosition->AlignedByteOffset) = Float3((float*)&(pAiPart->mVertices[i]));
*(Float3*)Get(vertices, i, stride, elemTangent->AlignedByteOffset) = Float3((float*)&(pAiPart->mTangents[i]));
*(Float3*)Get(vertices, i, stride, elemNormal->AlignedByteOffset) = Float3((float*)&(pAiPart->mNormals[i]));
auto elemTexCoord = elemTangent + 1;
for (int32 j = 0; j < numUVChannels; ++j)
{
aiVector3D texcoord = pAiPart->mTextureCoords[j][i];
*(Float2*)Get(vertices, i, stride, elemTexCoord->AlignedByteOffset) = Float2((float*)&(pAiPart->mTextureCoords[j][i]));
++elemTexCoord;
}
#if UV_MIRROR
float t = dot(cross(scene->mMeshes[meshIndex]->mNormals[i], scene->mMeshes[meshIndex]->mTangents[i]), scene->mMeshes[meshIndex]->mBitangents[i]);
if (t < 0)
vertices[i].Tangent = float3(-vertices[i].Tangent.r, vertices[i].Tangent.g, vertices[i].Tangent.b);
#endif
min.x = std::min(min.x, pAiPart->mVertices[i].x);
min.y = std::min(min.y, pAiPart->mVertices[i].y);
min.z = std::min(min.z, pAiPart->mVertices[i].z);
max.x = std::max(max.x, pAiPart->mVertices[i].x);
max.y = std::max(max.y, pAiPart->mVertices[i].y);
max.z = std::max(max.z, pAiPart->mVertices[i].z);
}
part->m_Size = std::max(max.x - min.x, std::max(max.y - min.y, max.z - min.z));
part->m_Center = Float3((min.x + max.x) / 2.0f, (min.y + max.y) / 2.0f, (min.z + max.z) / 2.0f);
for (long long i = 0; i < numFaces; ++i)
{
aiFace* face = &(scene->mMeshes[meshIndex]->mFaces[i]);
indices[3 * i] = face->mIndices[0];
indices[3 * i + 1] = face->mIndices[1];
indices[3 * i + 2] = face->mIndices[2];
assert(
indices[3 * i] <= numVertices &&
indices[3 * i + 1] <= numVertices &&
indices[3 * i + 2] <= numVertices
);
}
//.........这里部分代码省略.........
示例9: main
int main()
{
int n = -1;
int flag = 0;
int flag1;
int save;
struct Node * head;
char fileName[20] = "0";
flag = SignIn(); //登陆
if(flag == 1)
{
head = InitLink(); //初始化
}
for(;;) //各种功能 一直循环
{
fflush(stdin);
flag = 1;
ReturnDesk();
system("clear");
ShowDesk();
fflush(stdin);
scanf("%d", &n);
fflush(stdin);
if(n == 0)
{
system("clear");
FreeAllNodes(head);
printf("\n\n\n\n\n\n 谢谢使用, ----made by Mr.Du 丶Lun\n\n\n\n\n\n");
getch();
exit(0);
}//if
if(n == 1)
{
system("clear");
Print(head);
}//if
if(n == 4)
{
system("clear");
head = Sort(head);
printf("sort over,new info:\n\n\n");
Print(head);
}
if(n == 5)
{
system("clear");
Print(head);
Insert(head);
system("clear");
printf("insert over\n");
Print(head);
}
if(n == 6)
{
system("clear");
Print(head);
Remove(&head);
system("clear");
printf("remove over new info:\n");
Print(head);
}
if(n == 8)
{
system("clear");
Print(head);
head =AddNodeBefore(head);
}
if(n == 9)
{
system("clear");
Print(head);
AddNodeAfter(head);
}
if(n == 10)
{
system("clear");
printf("倒序排列为:\n");
head = Reverse(head);
Print(head);
}
if(n == 11)
{
system("clear");
if(flag1 == -1)
{
Save_now_info(head, fileName);
save = 1;
}
else
{
//printf("%d", flag);
save = Save_info(head);
}
if(save == 1)
//.........这里部分代码省略.........
示例10: Insert
/// An equivalent to Insert(A), but more readable.
void operator += (const ArrayT< Vector3T<T> >& A) { Insert(A); }
示例11: lru_insert
void lru_insert( Node *use_blk, Node *new_def ) { Insert(use_blk,new_def); }
示例12: Insert
//C-String Implementation of operator +=
ZBasicString<A>& operator += (const char *_other)
{ Insert(Length(), _other); return *this; }
示例13: Insert
//---------------------------------------------------------------------------
void __fastcall TCopyParamList::Add(const UnicodeString Name,
TCopyParamType * CopyParam, TCopyParamRule * Rule)
{
Insert(Count, Name, CopyParam, Rule);
}
示例14: main
int main(int argc, char * argv[]) {
int numOfLists, sizeOfLists, i, j, bufferItem;
double bubBest1, bubWorst1, bubAvg1, bubBest2, bubWorst2, bubAvg2, bubBest3, bubWorst3, bubAvg3, sum1, sum2, sum3;
List Lists[1000];
List bufferList;
clock_t start1,end1, start2, end2, start3, end3;
srand(time(NULL));
if ((argc < 3) || (argc > 3)) { /*Checks preconditions for program*/
printf("**Invalid number of arguments to run program**\n\n**Program will terminate now\n");
return 1;
}
numOfLists = atoi(argv[1]);
sizeOfLists = atoi(argv[2]); /*only lists of size 1000 and up to 1000 lists are supported*/
if ((numOfLists>1000) || (numOfLists<=2) || (sizeOfLists>1000) || (sizeOfLists<=2)) {
printf("**Invalid integer entered**\nOnly integers between 3 and 1000 are allowed\nProgram will terminate now\n");
return 1;
}
Initialize(&bufferList);
for (i=0; i<sizeOfLists; i++) { /*Create two mandatory Lists*/
Insert(i+1, i, &Lists[0]);
Insert(sizeOfLists-i, i, &Lists[1]);
}
for (i=2; i<numOfLists; i++) {
for (j=0; j<sizeOfLists; j++) {
bufferItem = (rand() %343+1); /*Create random lists*/
Insert(bufferItem, bufferList.size, &bufferList);
}
Lists[i] = bufferList;
Initialize(&bufferList);
}
sum1=0;
bubAvg1 = 0;
start1 = clock(); /*Starts Timer*/
BubbleSort1(Lists[0]);
end1 = clock();
bubBest1 = (double)(end1-start1)/CLOCKS_PER_SEC;
start2 = clock();
BubbleSort1(Lists[1]);
end2 = clock();
bubWorst1 = (double)(end2-start2)/CLOCKS_PER_SEC;
for (i=0; i<numOfLists; i++) {
start3 = clock();
BubbleSort1(Lists[i]);
end3 = clock();
sum1 = ((double)(end3-start3)/CLOCKS_PER_SEC);
bubAvg1 = bubAvg1 + sum1; /*Finds the Average*/
}
bubAvg1 = bubAvg1/numOfLists;
printf("\nBubbleSort1\n%f\n%f\n%f\n", bubBest1, bubAvg1, bubWorst1);
sum2=0;
bubAvg2 = 0;
start1 = clock();
BubbleSort2(Lists[0]);
end1 = clock();
bubBest2 = (double)(end1-start1)/CLOCKS_PER_SEC;
start2 = clock();
BubbleSort2(Lists[1]);
end2 = clock();
bubWorst2 = (double)(end2-start2)/CLOCKS_PER_SEC;
for (i=0; i<numOfLists; i++) {
start3 = clock();
BubbleSort2(Lists[i]);
end3 = clock();
sum2 = ((double)(end3-start3)/CLOCKS_PER_SEC);
bubAvg2 = bubAvg2 + sum2;
}
bubAvg2 = bubAvg2/numOfLists;
printf("\nBubbleSort2\n%f\n%f\n%f\n", bubBest2, bubAvg2, bubWorst2);
sum3=0;
bubAvg3 = 0;
start1 = clock();
MergeSort(&Lists[0], 0, Lists[0].size-1);
end1 = clock();
bubBest3 = (double)(end1-start1)/CLOCKS_PER_SEC;
start2 = clock();
MergeSort(&Lists[1], 0, Lists[1].size-1);
end2 = clock();
bubWorst3 = (double)(end2-start2)/CLOCKS_PER_SEC;
for (i=0; i<numOfLists; i++) {
start3 = clock();
MergeSort(&Lists[i], 0, Lists[i].size-1);
end3 = clock();
sum3 = ((double)(end3-start3)/CLOCKS_PER_SEC);
bubAvg3 = bubAvg3 + sum3;
}
bubAvg3 = bubAvg3/numOfLists;
printf("\nMergeSort\n%f\n%f\n%f\n", bubBest3, bubAvg3, bubWorst3);
//.........这里部分代码省略.........
示例15: Insert
void Insert()
{
int j;
for(j=tot;j>0;j--)
{
cur=tar[j];
if(cur.edgs==temp.edgs)
{
if(Yes())
{
if(cur.edge==temp.edge)
{
tar[j]=temp;
return;
}
else if(cur.edge<temp.edge)
{
temp.edgs=tar[j].edge;
tar[j].sx=temp.sx;
tar[j].sy=temp.sy;
tar[j].ex=temp.ex;
tar[j].ey=temp.ey;
Insert();
return;
}
else
{
tar[j].edgs=temp.edge;
tot++;
tar[tot]=temp;
return;
}
}
else
{
if(cur.edge==temp.edge)
{
return;
}
else if(cur.edge<temp.edge)
{
temp.edgs=tar[j].edge;
Insert();
return;
}
else
{
tar[j].edgs=temp.edge;
tot++;
tar[tot]=cur;
tar[tot].edge=temp.edge;
return;
}
}
}
else if(cur.edge==temp.edge)
{
if(Yes())
{
if(cur.edgs<temp.edgs)
{
tar[j].edge=temp.edgs;
tot++;
tar[tot]=temp;
return;
}
else
{
temp.edge=tar[j].edgs;
tar[j].sx=temp.sx;
tar[j].sy=temp.sy;
tar[j].ex=temp.ex;
tar[j].ey=temp.ey;
Insert();
return;
}
}
else
{
if(cur.edgs<temp.edgs)
{
tar[j].edge=temp.edgs;
tot++;
tar[tot]=tar[j];
tar[tot].edgs=temp.edgs;
tar[tot].edge=temp.edge;
return;
}
else
{
temp.edge=tar[j].edgs;
Insert();
return;
}
}
}
}
tot++;
//.........这里部分代码省略.........