本文整理汇总了C++中Page::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Page::GetSize方法的具体用法?C++ Page::GetSize怎么用?C++ Page::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::GetSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SwapR
Page* Page::SwapR()
{
for (uint i = 0; i < this->GetSize(); i++)
{
if (child[i] != NULL)
{
Page* pp = child[i]->SwapR();
if (pp != NULL)
{
//cout << "new child for " << (child[i])->keys[0] << " == " << pp->keys[0] << endl;
child[i] = pp;
}
}
}
if (child[0] != NULL && child[GetSize()] != NULL)
{
int ls = child[0]->GetDepth();
int rs = child[GetSize()]->GetDepth();
if (ls >= rs + 2)
{
Page* l = child[0];
{
if (l->child[l->GetSize()] == NULL)
{
//cout << "new child for " << (l)->keys[0] << " = " << keys[0] << endl;
l->child[l->GetSize()] = this;
child[0] = NULL;
return l;
}
}
}
}
return NULL;
}
示例2: merge
void Page::merge()
{
bool ok = false;
for (uint i = 0; i < child.size(); i++)
{
if (child[i] != NULL)
{
(child[i])->merge();
Page* buff = child[i];
if (buff->GetSize() < 2 * _t + 1 - GetSize())
{
child.erase(child.begin()+i);
for (int j = buff->GetSize() - 1; j >= 0; j--)
{
keys.insert(keys.begin()+i, buff->GetKey(j));
child.insert(child.begin()+i, buff->GetChildren(j + 1));
}
child.insert(child.begin()+i, buff->GetChildren(0));
ok = true;
for (uint k = 0; k < buff->keys.size()-1; k++)
{
buff->child.erase(child.begin());
buff->keys.erase(keys.begin());
}
buff->child.erase(child.begin());
break;
}
if (ok) break;
}
}
}
示例3: Balance
bool Page::Balance(int* val, Page* rw)
{
if (this->keys.size() == 2*_t+1)
{
*val = this->keys.at(_t);
this->keys.erase(keys.begin()+_t);
rw->RemoveChildren(0);
// after all size is 2*t
for (uint i = 0; i < _t ; i++)
{
rw->AddChildren(this->child.at(_t+1));
this->child.erase(child.begin()+_t + 1);
rw->addToKeys(this->keys.at(_t));
this->keys.erase(keys.begin() + _t);
}
rw->AddChildren(this->child.at(_t+1));
this->child.erase(child.begin()+_t + 1);
return true;
}
else
{
for (uint i = 0; i < this->child.size(); i++)
if (child.at(i) != NULL)
{
int v=-1;
Page* r = new Page(_t);
r->RemoveChildren(0);
bool isNotBalanced = this->child.at(i)->Balance(&v, r);
if (r->GetSize()>0)
{
this->child.insert(child.begin() + i+1, r);
this->keys.insert(keys.begin() + i, v);
}
if (isNotBalanced)
return true;
}
}
return false;
}
示例4: Pack
void PackToBin::Pack(const std::string& filepath,
const ee::TexturePacker& tp,
bool compress,
float scale)
{
std::set<int> ref_pkgs;
uint32_t default_sym_id = 0xffffffff;
const std::string default_sym_path = ee::ImageDataMgr::Instance()->GetDefaultSym();
if (!default_sym_path.empty()) {
int pkg_id, node_id;
PackIDMgr::Instance()->QueryID(default_sym_path, pkg_id, node_id, true);
default_sym_id = simp::NodeID::ComposeID(pkg_id, node_id);
}
// src nodes
std::vector<PackNode*> nodes;
PackNodeFactory::Instance()->FetchAll(nodes);
std::vector<PackNode*>::iterator itr = nodes.begin();
for ( ; itr != nodes.end(); )
{
PackNode* node = *itr;
if (!PackIDMgr::Instance()->IsCurrPkg(node)) {
ref_pkgs.insert(node->GetPkgID());
itr = nodes.erase(itr);
} else {
if (default_sym_id != 0xffffffff && default_sym_id == node->GetID() &&
default_sym_path != node->GetFilepath()) {
itr = nodes.erase(itr);
} else {
++itr;
}
}
}
if (nodes.empty()) {
return;
}
std::sort(nodes.begin(), nodes.end(), PackNodeCmp());
// to pages
std::vector<Page*> pages;
Page* page = new Page(simp::SIMP_PAGE_SIZE);
int page_sz = ALIGN_4BYTE(simp::Page::Size());
for (int i = 0, n = nodes.size(); i < n; ++i)
{
PackNode* node = nodes[i];
int sz = node->SizeOfUnpackFromBin();
while (true)
{
// head sz
int num;
auto& page_nodes = page->GetNodes();
if (page_nodes.empty()) {
num = 1;
} else {
num = node->GetID() - page_nodes[0]->GetID() + 1;
}
int align_n = ALIGN_4BYTE(num);
int head_sz =
sizeof(uint8_t) * align_n + // types
simp::SIZEOF_POINTER * num; // nodes
if (page_sz + head_sz + sz <= page->GetSize()) {
page_sz += sz;
page->Add(node);
break;
}
if (page->NodeNum() > 0) {
page->Condense(page_sz + head_sz);
pages.push_back(page);
page = new Page(simp::SIMP_PAGE_SIZE);
page_sz = ALIGN_4BYTE(simp::Page::Size());
} else {
page->Enlarge();
}
}
}
if (page->NodeNum() > 0)
{
// head sz
auto& page_nodes = page->GetNodes();
int num = page_nodes.back()->GetID() - page_nodes.front()->GetID() + 1;
int align_n = ALIGN_4BYTE(num);
int head_sz =
sizeof(uint8_t) * align_n + // types
simp::SIZEOF_POINTER * num; // nodes
page->Condense(page_sz + head_sz);
pages.push_back(page);
}
// pack index
PageIndex(filepath + ".epe", pages, compress, scale, ref_pkgs);
// pack pages
for (int i = 0, n = pages.size(); i < n; ++i) {
std::string path = filepath + "." + ee::StringHelper::ToString(i + 1) + ".epe";
PackPage(path, *pages[i], tp, compress);
}
}
示例5: rDst
void IW::CRender::DrawToDC(HDC hdc, const Page &page, const CPoint &point)
{
const CRect rDst(point, page.GetSize());
DrawToDC(hdc, page, rDst);
}