本文整理汇总了C++中GList类的典型用法代码示例。如果您正苦于以下问题:C++ GList类的具体用法?C++ GList怎么用?C++ GList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
DjVuTXT::Zone::get_smallest(GList<GRect> &list, const int padding) const
{
GPosition pos=children;
if(pos)
{
do {
children[pos].get_smallest(list,padding);
} while (++pos);
}
else if(zone_parent && zone_parent->ztype >= PARAGRAPH)
{
const GRect &xrect=zone_parent->rect;
if(xrect.height() < xrect.width())
{
list.append(GRect(rect.xmin-padding,xrect.ymin-padding,rect.width()
+2*padding,xrect.height()+2*padding));
}
else
{
list.append(GRect(xrect.xmin-padding,rect.ymin-padding,xrect.width()
+2*padding,rect.height()+2*padding));
}
}
else
{
list.append(GRect(rect.xmin-padding,rect.ymin-padding,rect.width()
+2*padding,rect.height()+2*padding));
}
}
示例2: g_set_application_name
/*
This should be replaced by more convenient method of accessing gnome-keyring..
We have very unnecessery dependecies with gnome devs here.
*/
const QStringList DesktopCouchProvider::getOAuthCredentials(void)
{
QLog::getLogger()->log("Retrieving credentials...",QLog::INFO);
//QStringList* creds = NULL;
g_set_application_name("desktop-couch-qt");
GnomeKeyringAttributeList* attributes;
GnomeKeyringResult result;
GList* found_list;
GList* i;
GnomeKeyringFound * found;
attributes = g_array_new(FALSE, FALSE, sizeof (GnomeKeyringAttribute));
gnome_keyring_attribute_list_append_string(attributes,"desktopcouch","oauth");
result = gnome_keyring_find_items_sync(GNOME_KEYRING_ITEM_GENERIC_SECRET,attributes,&found_list);
char* item;
if (result == GNOME_KEYRING_RESULT_OK )
{
for ( i = found_list; i != NULL; i = i->next )
{
found = (GnomeKeyringFound*)i->data;
item = g_strdup(found->secret);
QString i(item);
QStringList lcreds = i.split(":");
return lcreds;
}
}
QLog::getLogger()->log("Retrieving credentials failed...\n(check if Gnome-Keyring-Daemon is running)",QLog::ERROR);
return QStringList();
}
示例3: qsearch_mrnas
int qsearch_mrnas(uint x, GList<GffObj>& mrnas) {
//binary search
//do the simplest tests first:
if (mrnas[0]->start>x) return 0;
if (mrnas.Last()->start<x) return -1;
uint istart=0;
int i=0;
int idx=-1;
int maxh=mrnas.Count()-1;
int l=0;
int h = maxh;
while (l <= h) {
i = (l+h)>>1;
istart=mrnas[i]->start;
if (istart < x) l = i + 1;
else {
if (istart == x) { //found matching coordinate here
idx=i;
while (idx<=maxh && mrnas[idx]->start==x) {
idx++;
}
return (idx>maxh) ? -1 : idx;
}
h = i - 1;
}
} //while
idx = l;
while (idx<=maxh && mrnas[idx]->start<=x) {
idx++;
}
return (idx>maxh) ? -1 : idx;
}
示例4: qsearch_loci
int qsearch_loci(uint x, GList<GLocus>& loci) {
// same as above, but for GSeg lists
//binary search
//do the simplest tests first:
if (loci[0]->start>x) return 0;
if (loci.Last()->start<x) return -1;
uint istart=0;
int i=0;
int idx=-1;
int maxh=loci.Count()-1;
int l=0;
int h = maxh;
while (l <= h) {
i = (l + h) >> 1;
istart=loci[i]->start;
if (istart < x) l=i+1;
else {
if (istart == x) { //found matching coordinate here
idx=i;
while (idx<=maxh && loci[idx]->start==x) {
idx++;
}
return (idx>maxh) ? -1 : idx;
}
h=i-1;
}
} //while
idx = l;
while (idx<=maxh && loci[idx]->start<=x) {
idx++;
}
return (idx>maxh) ? -1 : idx;
}
示例5: getCIDToUnicodeNames
/* copied from xpdf/GlobalParams.cc as it was removed in XPDF 4 */
GList* getCIDToUnicodeNames(GlobalParams* globalParams) {
GList *list = new GList();
GString *key;
void *value;
GHashIter *iter = NULL;
globalParams->cidToUnicodes->startIter(&iter);
while (globalParams->cidToUnicodes->getNext(&iter, &key, &value)) {
list->append(key->copy());
}
globalParams->cidToUnicodes->killIter(&iter);
return list;
}
示例6: assert
QCyclicGroup::QCyclicGroup(const gint size)
{
assert(size > 0);
GList e;
for(int i = 0; i < size; ++i)
{
e.append(i);
}
this->createCyclic(e);
}
示例7: gthread_cond_wait
InterfaceInstance *GetInterface(const char *pzModelType)
{
if (m_nThreadMode == 1 || m_nThreadMode == 2)
{
if(m_nThreadMode == 1)
{
// wait for the one and only
gthread_cond_wait(&m_cond, &m_condLock);
}
InterfaceInstance *pII = (InterfaceInstance *)m_lstInterfaces.First();
pII->InUse(1);
return pII;
}
if (m_nThreadMode == 3)
{
// find one that's not in use
gthread_mutex_lock(&m_lock);
InterfaceInstance *pII = 0;
GListIterator it(&m_lstInterfaces);
while (it())
{
pII = (InterfaceInstance *)it++;
if ( !pII->InUse() )
{
pII->InUse(1);
gthread_mutex_unlock(&m_lock);
return pII; // and return it
}
}
// unlock the mutex while we create a new instance, this will take a while
gthread_mutex_unlock(&m_lock);
pII = new InterfaceInstance(pzModelType);
pII->InUse(1);
gthread_mutex_lock(&m_lock);
// store the instance then return it
m_lstInterfaces.AddLast(pII);
gthread_mutex_unlock(&m_lock);
return pII;
}
else if (m_nThreadMode == 4)
{
return new InterfaceInstance(pzModelType);
}
return 0;
}
示例8: cluster_mRNAs
void cluster_mRNAs(GList<GffObj> & mrnas, GList<GLocus> & loci, int qfidx) {
//mrnas sorted by start coordinate
//and so are the loci
//int rdisc=0;
for (int t=0;t<mrnas.Count();t++) {
GArray<int> mrgloci(false);
GffObj* mrna=mrnas[t];
int lfound=0; //count of parent loci
/*for (int l=0;l<loci.Count();l++) {
if (loci[l]->end<mrna->exons.First()->start) continue;
if (loci[l]->start>mrna->exons.Last()->end) break; */
for (int l=loci.Count()-1;l>=0;l--) {
if (loci[l]->end<mrna->exons.First()->start) {
if (mrna->exons.First()->start-loci[l]->start > GFF_MAX_LOCUS) break;
continue;
}
if (loci[l]->start>mrna->exons.Last()->end) continue;
//here we have mrna overlapping loci[l]
if (loci[l]->add_mRNA(mrna)) {
//a parent locus was found
lfound++;
mrgloci.Add(l); //locus indices added here, in decreasing order
}
}//loci loop
//if (lfound<0) continue; //mrna was a ref duplicate, skip it
if (lfound==0) {
//create a locus with only this mRNA
loci.Add(new GLocus(mrna, qfidx));
}
else if (lfound>1) {
//more than one locus found parenting this mRNA, merge loci
lfound--;
for (int l=0;l<lfound;l++) {
int mlidx=mrgloci[l]; //largest indices first, so it's safe to remove
loci[mrgloci[lfound]]->addMerge(*loci[mlidx], mrna);
loci.Delete(mlidx);
}
}
}//mrnas loop
//if (rdisc>0) mrnas.Pack();
//return rdisc;
}
示例9: appendPath
static void
appendPath(const GURL &url,
GMap<GUTF8String,void *> &map,
GList<GURL> &list)
{
if( !url.is_empty() && !map.contains(url.get_string()) )
{
map[url.get_string()]=0;
list.append(url);
}
}
示例10: collectLocusData
void collectLocusData(GList<GenomicSeqData>& ref_data) {
int locus_num=0;
for (int g=0;g<ref_data.Count();g++) {
GenomicSeqData* gdata=ref_data[g];
for (int l=0;l<gdata->loci.Count();l++) {
GffLocus& loc=*(gdata->loci[l]);
GHash<int> gnames(true); //gene names in this locus
GHash<int> geneids(true); //Entrez GeneID: numbers
for (int i=0;i<loc.rnas.Count();i++) {
GffObj& t=*(loc.rnas[i]);
GStr gname(t.getGeneName());
if (!gname.is_empty()) {
gname.upper();
int* prevg=gnames.Find(gname.chars());
if (prevg!=NULL) (*prevg)++;
else gnames.Add(gname, new int(1));
}
//parse GeneID xrefs, if any:
GStr xrefs(t.getAttr("xrefs"));
if (!xrefs.is_empty()) {
xrefs.startTokenize(",");
GStr token;
while (xrefs.nextToken(token)) {
token.upper();
if (token.startsWith("GENEID:")) {
token.cut(0,token.index(':')+1);
int* prevg=geneids.Find(token.chars());
if (prevg!=NULL) (*prevg)++;
else geneids.Add(token, new int(1));
}
} //for each xref
} //xrefs parsing
}//for each transcript
locus_num++;
loc.locus_num=locus_num;
if (gnames.Count()>0) { //collect all gene names associated to this locus
gnames.startIterate();
int* gfreq=NULL;
char* key=NULL;
while ((gfreq=gnames.NextData(key))!=NULL) {
loc.gene_names.AddIfNew(new CGeneSym(key,*gfreq));
}
} //added collected gene_names
if (loc.gene_ids.Count()>0) { //collect all GeneIDs names associated to this locus
geneids.startIterate();
int* gfreq=NULL;
char* key=NULL;
while ((gfreq=geneids.NextData(key))!=NULL) {
loc.gene_ids.AddIfNew(new CGeneSym(key,*gfreq));
}
}
} //for each locus
}//for each genomic sequence
}
示例11: parsePATH
static GList<GURL>
parsePATH(void)
{
GList<GURL> retval;
const char *path=getenv("PATH");
if(path)
{
GNativeString p(path);
int from=0;
for(int to;(to=p.search(':',from))>0;from=to+1)
{
if(to > from)
{
retval.append(GURL::Filename::Native(p.substr(from,to-from)));
}
}
if((from+1)<(int)p.length())
{
retval.append(GURL::Filename::Native(p.substr(from,-1)));
}
}
return retval;
}
示例12: while
void
DjVuTXT::Zone::get_smallest(GList<GRect> &list) const
{
GPosition pos=children;
if(pos)
{
do {
children[pos].get_smallest(list);
} while (++pos);
}
else
{
list.append(rect);
}
}
示例13: intList
// helper function for args
static void
intList(GUTF8String coords, GList<int> &retval)
{
int pos=0;
while(coords.length())
{
int epos;
unsigned long i=coords.toLong(pos,epos,10);
if(epos>=0)
{
retval.append(i);
const int n=coords.nextNonSpace(epos);
if(coords[n] != ',')
break;
pos=n+1;
}
}
}
示例14: main
int main()
{
Grocery item; // testing default constructor
Grocery item2("carrots", 8, false); //testing constructor with perameters
item2.print();
cout << endl;
item.setGrocery("eggs", 5, true); //testing set grocery function
item.print();
cout << endl;
item.changeAmount(-3);//testing changeamt function should work
item.print();
cout << endl;
item.changeAmount(4);//testing changeamt function should work
item.print();
cout << endl;
item.changeAmount(-100);//testing change amt function shouldn't work
item.print();
cout << "\nGLIST STUFF\n";
GList one; // testing default constructor
one.insert("bacon",12,false); // testing insert fuction
one.insert(item);
one.print(); // testing print function
one.erase("bacon",false);
one.print();
one.updateItem("bacon",12); // test updating item not in list
one.print();
one.updateItem("eggs",-1200); //test updating eggs shouldn't work
one.print();
one.updateItem("eggs",12); // test updating eggs should work
one.print();
one.insert("Ketchup",50,false); //should print under Costco
one.insert("Kumquat",3,false); //Should print under Safeway
one.insert("Mustard",50,true); //Should print under Costco
one.insert("Potato",7,true); //Should print under Whole Foods
one.printByStore();
}
示例15: read_mRNAs
void read_mRNAs(FILE* f, GList<GSeqData>& seqdata, GList<GSeqData>* ref_data,
int check_for_dups, int qfidx, const char* fname, bool only_multiexon) {
//>>>>> read all transcripts/features from a GTF/GFF3 file
//int imrna_counter=0;
#ifdef HEAPROFILE
if (IsHeapProfilerRunning())
HeapProfilerDump("00");
#endif
int loci_counter=0;
if (ref_data==NULL) ref_data=&seqdata;
bool isRefData=(&seqdata==ref_data);
//(f, transcripts_only)
GffReader* gffr=new GffReader(f, true); //load only transcript annotations
gffr->showWarnings(gtf_tracking_verbose);
// keepAttrs mergeCloseExons noExonAttrs
gffr->readAll(!isRefData, true, isRefData || gtf_tracking_largeScale);
//so it will read exon attributes only for low number of Cufflinks files
#ifdef HEAPROFILE
if (IsHeapProfilerRunning())
HeapProfilerDump("post_readAll");
#endif
int d=parse_mRNAs(gffr->gflst, seqdata, isRefData, check_for_dups, qfidx,only_multiexon);
#ifdef HEAPROFILE
if (IsHeapProfilerRunning())
HeapProfilerDump("post_parse_mRNAs");
#endif
if (gtf_tracking_verbose && d>0) {
if (isRefData) GMessage(" %d duplicate reference transcripts discarded.\n",d);
else GMessage(" %d redundant query transfrags discarded.\n",d);
}
//imrna_counter=gffr->mrnas.Count();
delete gffr; //free the extra memory and unused GffObjs
#ifdef HEAPROFILE
if (IsHeapProfilerRunning())
HeapProfilerDump("post_del_gffr");
#endif
//for each genomic sequence, cluster transcripts
int oriented_by_overlap=0;
int initial_unoriented=0;
int final_unoriented=0;
GStr bname(fname);
GStr s;
if (!bname.is_empty()) {
int di=bname.rindex('.');
if (di>0) bname.cut(di);
int p=bname.rindex('/');
if (p<0) p=bname.rindex('\\');
if (p>=0) bname.remove(0,p);
}
FILE* fdis=NULL;
FILE* frloci=NULL;
for (int g=0;g<seqdata.Count();g++) {
//find the corresponding refseqdata with the same gseq_id
int gseq_id=seqdata[g]->get_gseqid();
if (!isRefData) { //query data, find corresponding ref data
GSeqData* rdata=getRefData(gseq_id, *ref_data);
initial_unoriented+=seqdata[g]->umrnas.Count();
if (seqdata[g]->umrnas.Count()>0) {
oriented_by_overlap+=fix_umrnas(*seqdata[g], rdata, fdis);
final_unoriented+=seqdata[g]->umrnas.Count();
}
}
//>>>>> group mRNAs into locus-clusters (based on exon overlap)
cluster_mRNAs(seqdata[g]->mrnas_f, seqdata[g]->loci_f, qfidx);
cluster_mRNAs(seqdata[g]->mrnas_r, seqdata[g]->loci_r, qfidx);
if (!isRefData) {
cluster_mRNAs(seqdata[g]->umrnas, seqdata[g]->nloci_u, qfidx);
}
loci_counter+=seqdata[g]->loci_f.Count();
loci_counter+=seqdata[g]->loci_r.Count();
// if (refData) {
// if (frloci==NULL) {
// s=bname;
// s.append(".loci.lst");
// frloci=fopen(s.chars(), "w");
// }
// writeLoci(frloci, seqdata[g]->loci_f);
// writeLoci(frloci, seqdata[g]->loci_r);
// }//write ref loci
}//for each genomic sequence
if (fdis!=NULL) fclose(fdis);
if (frloci!=NULL) fclose(frloci);
if (initial_unoriented || final_unoriented) {
if (gtf_tracking_verbose) GMessage(" Found %d transfrags with undetermined strand (%d out of initial %d were fixed by overlaps)\n",
final_unoriented, oriented_by_overlap, initial_unoriented);
}
//if (fdis!=NULL) remove(s.chars()); remove 0-length file
#ifdef HEAPROFILE
if (IsHeapProfilerRunning())
HeapProfilerDump("post_cluster");
#endif
}