Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
213f9056
Commit
213f9056
authored
16 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
add functions to manage a hash of GQuark -> Glist's of GQuarks
parent
01d38b07
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/ZMap/zmapGLibUtils.h
+8
-2
8 additions, 2 deletions
src/include/ZMap/zmapGLibUtils.h
src/zmapUtils/zmapGLibUtils.c
+109
-7
109 additions, 7 deletions
src/zmapUtils/zmapGLibUtils.c
with
117 additions
and
9 deletions
src/include/ZMap/zmapGLibUtils.h
+
8
−
2
View file @
213f9056
...
...
@@ -26,9 +26,9 @@
* glib but not included with their distribution.
*
* HISTORY:
* Last edited:
Mar 24 10:24
2009 (edgrif)
* Last edited:
Apr 16 08:52
2009 (edgrif)
* Created: Thu Oct 13 15:56:54 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.h,v 1.
19
2009-04-
03 15:41
:1
8
edgrif Exp $
* CVS info: $Id: zmapGLibUtils.h,v 1.
20
2009-04-
16 09:05
:1
9
edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_GLIBUTILS_H
...
...
@@ -81,8 +81,14 @@ GList *zMap_g_list_raise(GList *move, int positions);
GList
*
zMap_g_list_split
(
GList
*
list
,
GList
*
new_list_head
)
;
gpointer
zMap_g_hash_table_nth
(
GHashTable
*
hash_table
,
int
nth
)
;
GHashTable
*
zMap_g_hashlist_create
(
void
)
;
gboolean
zMap_g_string_replace
(
GString
*
string
,
char
*
target
,
char
*
source
)
;
void
zMap_g_hashlist_insert
(
GHashTable
*
hashlist
,
GQuark
key
,
gpointer
value
)
;
void
zMap_g_hashlist_insert
(
GHashTable
*
hashlsit
,
GQuark
key
,
gpointer
value
)
;
GHashTable
*
zMap_g_hashlist_copy
(
GHashTable
*
orig_hashlist
)
;
void
zMap_g_hashlist_destroy
(
GHashTable
*
hashlist
)
;
/* Returns a pointer to an element of the array instead of the element itself. */
...
...
This diff is collapsed.
Click to expand it.
src/zmapUtils/zmapGLibUtils.c
+
109
−
7
View file @
213f9056
...
...
@@ -26,9 +26,9 @@
*
* Exported functions: See ZMap/zmapGLibUtils.h
* HISTORY:
* Last edited:
Mar 24 13:07
2009 (edgrif)
* Last edited:
Apr 16 08:54
2009 (edgrif)
* Created: Thu Oct 13 15:22:35 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.c,v 1.2
6
2009-04-
03 15:41
:1
8
edgrif Exp $
* CVS info: $Id: zmapGLibUtils.c,v 1.2
7
2009-04-
16 09:05
:1
9
edgrif Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -80,7 +80,10 @@ static void printCB(gpointer data, gpointer user_data) ;
static
gint
caseCompareFunc
(
gconstpointer
a
,
gconstpointer
b
)
;
static
void
get_datalist_length
(
GQuark
key
,
gpointer
data
,
gpointer
user_data
);
static
void
get_first_datalist_key
(
GQuark
id
,
gpointer
data
,
gpointer
user_data
);
gboolean
getNthHashElement
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
;
static
gboolean
getNthHashElement
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
;
static
void
hashCopyListCB
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
;
static
void
destroyList
(
gpointer
data
)
;
/*! @defgroup zmapGLibutils zMapGLibUtils: glib-derived utilities for ZMap
...
...
@@ -98,7 +101,7 @@ gboolean getNthHashElement(gpointer key, gpointer value, gpointer user_data) ;
* */
/*
/*
!
* Additions to String utilities
*/
...
...
@@ -179,7 +182,7 @@ gchar *zMap_g_ascii_strstrcasecmp(const gchar *haystack, const gchar *needle)
/*
/*
!
* Additions to GList
*/
...
...
@@ -491,7 +494,7 @@ GList *zMap_g_list_split(GList *list, GList *new_list_head)
/*
/*
!
* Additions to GHash
*/
...
...
@@ -511,6 +514,71 @@ gpointer zMap_g_hash_table_nth(GHashTable *hash_table, int nth)
/*! A set of functions to handle a hash where each key is a GQuark and each entry is a
* simple list that can be directly copied. Several places in our code need to
* construct and look at his list hence these functions.
*
* Copy function could easily be extended to allow deep list copying with a callback.
* */
/* ! Make the hash of lists table. */
GHashTable
*
zMap_g_hashlist_create
(
void
)
{
GHashTable
*
new_hashlist
=
NULL
;
new_hashlist
=
g_hash_table_new_full
(
NULL
,
NULL
,
NULL
,
destroyList
)
;
return
new_hashlist
;
}
/* ! Insert a key value into the keyed list. */
void
zMap_g_hashlist_insert
(
GHashTable
*
hashlist
,
GQuark
key
,
gpointer
value
)
{
GList
*
list
;
/* Slightly tricky coding, if we don't find a list the append creates a new list,
* otherwise we append to the existing list. Either way we then _always_ replace
* the list in the hash as list start in theory could change. */
list
=
(
GList
*
)
g_hash_table_lookup
(
hashlist
,
GINT_TO_POINTER
(
key
))
;
list
=
g_list_append
(
list
,
value
)
;
g_hash_table_insert
(
hashlist
,
GINT_TO_POINTER
(
key
),
list
)
;
return
;
}
/*! Make a copy of the hash table of featureset names to styles lists. */
GHashTable
*
zMap_g_hashlist_copy
(
GHashTable
*
orig_hashlist
)
{
GHashTable
*
new_hashlist
=
NULL
;
new_hashlist
=
zMap_g_hashlist_create
()
;
g_hash_table_foreach
(
orig_hashlist
,
hashCopyListCB
,
new_hashlist
)
;
return
new_hashlist
;
}
void
zMap_g_hashlist_destroy
(
GHashTable
*
hashlist
)
{
g_hash_table_destroy
(
hashlist
)
;
return
;
}
/*
* Additions to GDatalist
*/
...
...
@@ -837,7 +905,7 @@ static void get_first_datalist_key(GQuark id, gpointer data, gpointer user_data)
*
* This function is NOT thread safe.
* */
gboolean
getNthHashElement
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
static
gboolean
getNthHashElement
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
{
gboolean
found_element
=
FALSE
;
static
int
n
=
0
;
...
...
@@ -853,3 +921,37 @@ gboolean getNthHashElement(gpointer key, gpointer value, gpointer user_data)
return
found_element
;
}
/* A GHFunc() to copy the list attached to a hash entry. */
static
void
hashCopyListCB
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
{
GList
*
orig_list
=
(
GList
*
)
value
;
GHashTable
*
new_hash
=
(
GHashTable
*
)
user_data
;
GList
*
new_list
=
NULL
;
new_list
=
g_list_copy
(
orig_list
)
;
g_hash_table_insert
(
new_hash
,
key
,
new_list
)
;
return
;
}
/* A GDestroyNotify() to free Glists held as the data in a hash. */
static
void
destroyList
(
gpointer
data
)
{
GList
*
list
=
(
GList
*
)
data
;
g_list_free
(
list
)
;
return
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment