本文整理汇总了C++中GList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ GList::size方法的具体用法?C++ GList::size怎么用?C++ GList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GList
的用法示例。
在下文中一共展示了GList::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCyclic
//创建循环群 I(rank)
void QCyclicGroup::createCyclic(const GList e)
{
assert(e.size() > 0);
this->m_list = e;
GMatrix matrix;
for(gint i = 0; i < e.size(); ++i)
{
GList s;
if(i == 0)
{
for(gint j = 0; j < e.size(); ++j)
{
s.append(j);
}
}
else
{
for(gint j = 0; j < e.size(); ++j)
{
if(j == 0)
{
s.append(i);
}
else
{
//怎么办,但是没有规则
}
}
}
for(gint j = 0; j < rank; j++)
{
t.append( (i+j)%rank );
}
matrix.append(t);
}
QPermuteGroup::createPermute(matrix);
}
示例2: if
int
DjVuPalette::compute_palette(int maxcolors, int minboxsize)
{
if (!hist)
G_THROW( ERR_MSG("DjVuPalette.no_color") );
if (maxcolors<1 || maxcolors>MAXPALETTESIZE)
G_THROW( ERR_MSG("DjVuPalette.many_colors") );
// Paul Heckbert: "Color Image Quantization for Frame Buffer Display",
// SIGGRAPH '82 Proceedings, page 297. (also in ppmquant)
// Collect histogram colors
int sum = 0;
int ncolors = 0;
GTArray<PData> pdata;
{ // extra nesting for windows
for (GPosition p = *hist; p; ++p)
{
pdata.touch(ncolors);
PData &data = pdata[ncolors++];
int k = hist->key(p);
data.p[0] = (k>>16) & 0xff;
data.p[1] = (k>>8) & 0xff;
data.p[2] = (k) & 0xff;
data.w = (*hist)[p];
sum += data.w;
}
}
// Create first box
GList<PBox> boxes;
PBox newbox;
newbox.data = pdata;
newbox.colors = ncolors;
newbox.boxsize = 256;
newbox.sum = sum;
boxes.append(newbox);
// Repeat spliting boxes
while (boxes.size() < maxcolors)
{
// Find suitable box
GPosition p;
for (p=boxes; p; ++p)
if (boxes[p].colors>=2 && boxes[p].boxsize>minboxsize)
break;
if (! p)
break;
// Find box boundaries
PBox &splitbox = boxes[p];
unsigned char pmax[3];
unsigned char pmin[3];
pmax[0] = pmin[0] = splitbox.data->p[0];
pmax[1] = pmin[1] = splitbox.data->p[1];
pmax[2] = pmin[2] = splitbox.data->p[2];
{ // extra nesting for windows
for (int j=1; j<splitbox.colors; j++)
{
pmax[0] = umax(pmax[0], splitbox.data[j].p[0]);
pmax[1] = umax(pmax[1], splitbox.data[j].p[1]);
pmax[2] = umax(pmax[2], splitbox.data[j].p[2]);
pmin[0] = umin(pmin[0], splitbox.data[j].p[0]);
pmin[1] = umin(pmin[1], splitbox.data[j].p[1]);
pmin[2] = umin(pmin[2], splitbox.data[j].p[2]);
}
}
// Determine split direction and sort
int bl = pmax[0]-pmin[0];
int gl = pmax[1]-pmin[1];
int rl = pmax[2]-pmin[2];
splitbox.boxsize = (bl>gl ? (rl>bl ? rl : bl) : (rl>gl ? rl : gl));
if (splitbox.boxsize <= minboxsize)
continue;
if (gl == splitbox.boxsize)
qsort(splitbox.data, splitbox.colors, sizeof(PData), gcomp);
else if (rl == splitbox.boxsize)
qsort(splitbox.data, splitbox.colors, sizeof(PData), rcomp);
else
qsort(splitbox.data, splitbox.colors, sizeof(PData), bcomp);
// Find median
int lowercolors = 0;
int lowersum = 0;
while (lowercolors<splitbox.colors-1 && lowersum+lowersum<splitbox.sum)
lowersum += splitbox.data[lowercolors++].w;
// Compute new boxes
newbox.data = splitbox.data + lowercolors;
newbox.colors = splitbox.colors - lowercolors;
newbox.sum = splitbox.sum - lowersum;
splitbox.colors = lowercolors;
splitbox.sum = lowersum;
// Insert boxes at proper location
GPosition q;
for (q=p; q; ++q)
if (boxes[q].sum < newbox.sum)
break;
boxes.insert_before(q, newbox);
for (q=p; q; ++q)
if (boxes[q].sum < splitbox.sum)
break;
boxes.insert_before(q, boxes, p);
}
// Fill palette array
//.........这里部分代码省略.........
示例3: if
GList<DjVuTXT::Zone *>
DjVuTXT::find_text_in_rect(GRect target_rect, GUTF8String &text) const
// returns a list of zones of type WORD in the nearest/selected paragraph
{
GList<Zone *> zone_list;
GList<Zone *> lines;
get_zones((int)PARAGRAPH, &page_zone, zone_list);
// it's possible that no paragraph structure exists for reasons that
// 1) ocr engine is not capable 2) file was modified by user. In such case,
// we can only make a rough guess, i.e., select all the lines intersected with
// target_rect
if (zone_list.isempty())
{
get_zones((int)LINE, &page_zone, zone_list);
GPosition pos;
for(pos=zone_list; pos; ++pos)
{
GRect rect=zone_list[pos]->rect;
int h0=rect.height()/2;
if(rect.intersect(rect,target_rect) && rect.height()>h0)
lines.append(zone_list[pos]);
}
} else
{
GPosition pos, pos_sel=zone_list;
float ar=0;
for(pos=zone_list; pos; ++pos)
{
GRect rect=zone_list[pos]->rect;
int area=rect.area();
if (rect.intersect(rect, target_rect))
{
float ftmp=rect.area()/(float)area;
if ( !ar || ar<ftmp )
{
ar=ftmp;
pos_sel=pos;
}
}
}
Zone *parag = 0;
if ( ar>0 ) parag=zone_list[pos_sel];
zone_list.empty();
if ( ar>0 )
{
get_zones((int)LINE, parag, zone_list);
if ( !zone_list.isempty() )
{
for(GPosition pos=zone_list; pos; ++pos)
{
GRect rect=zone_list[pos]->rect;
int h0=rect.height()/2;
if(rect.intersect(rect,target_rect) && rect.height()>h0)
lines.append(zone_list[pos]);
}
}
}
}
zone_list.empty();
if (!lines.isempty())
{
int i=1, lsize=lines.size();
GList<Zone *> words;
for (GPosition pos=lines; pos; ++pos, ++i)
{
words.empty();
get_zones((int)WORD, lines[pos], words);
if ( lsize==1 )
{
for(GPosition p=words;p;++p)
{
GRect rect=words[p]->rect;
if(rect.intersect(rect,target_rect))
//if (target_rect.contains(words[p]->rect))
zone_list.append(words[p]);
}
} else
{
if (i==1)
{
bool start=true;
for(GPosition p=words; p; ++p)
{
if ( start )
{
GRect rect=words[p]->rect;
if(rect.intersect(rect,target_rect))
//if (target_rect.contains(words[p]->rect))
{
start=false;
zone_list.append(words[p]);
}
} else
zone_list.append(words[p]);
}
} else if (i==lsize)
//.........这里部分代码省略.........