mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 10:16:17 +01:00
New functions to remove a range of elements from an array. (#94879, Nalin
2003-07-26 Matthias Clasen <maclas@gmx.de> * glib/garray.h: * glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements from an array. (#94879, Nalin Dahyabhai)
This commit is contained in:
parent
ffa186dfc9
commit
971af34af9
@ -1,5 +1,9 @@
|
|||||||
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/garray.h:
|
||||||
|
* glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
|
||||||
|
from an array. (#94879, Nalin Dahyabhai)
|
||||||
|
|
||||||
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
||||||
case.
|
case.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/garray.h:
|
||||||
|
* glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
|
||||||
|
from an array. (#94879, Nalin Dahyabhai)
|
||||||
|
|
||||||
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
||||||
case.
|
case.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/garray.h:
|
||||||
|
* glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
|
||||||
|
from an array. (#94879, Nalin Dahyabhai)
|
||||||
|
|
||||||
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
||||||
case.
|
case.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/garray.h:
|
||||||
|
* glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
|
||||||
|
from an array. (#94879, Nalin Dahyabhai)
|
||||||
|
|
||||||
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
||||||
case.
|
case.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/garray.h:
|
||||||
|
* glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
|
||||||
|
from an array. (#94879, Nalin Dahyabhai)
|
||||||
|
|
||||||
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
||||||
case.
|
case.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/garray.h:
|
||||||
|
* glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
|
||||||
|
from an array. (#94879, Nalin Dahyabhai)
|
||||||
|
|
||||||
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
|
||||||
case.
|
case.
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
2003-07-26 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/tmpl/arrays.sgml:
|
||||||
|
* glib/tmpl/arrays_byte.sgml:
|
||||||
|
* glib/tmpl/arrays_pointer.sgml:
|
||||||
|
* glib/glib-sections.txt: Add g_{,byte,pointer}_array_remove_range. (#94879, Nalin Dahyabhai)
|
||||||
|
|
||||||
* glib/tmpl/messages.sgml: Remove the note about the message length restriction.
|
* glib/tmpl/messages.sgml: Remove the note about the message length restriction.
|
||||||
|
|
||||||
2003-07-24 Matthias Clasen <maclas@gmx.de>
|
2003-07-24 Matthias Clasen <maclas@gmx.de>
|
||||||
|
@ -1588,6 +1588,7 @@ g_array_insert_val
|
|||||||
g_array_insert_vals
|
g_array_insert_vals
|
||||||
g_array_remove_index
|
g_array_remove_index
|
||||||
g_array_remove_index_fast
|
g_array_remove_index_fast
|
||||||
|
g_array_remove_range
|
||||||
g_array_sort
|
g_array_sort
|
||||||
g_array_sort_with_data
|
g_array_sort_with_data
|
||||||
g_array_index
|
g_array_index
|
||||||
@ -1606,6 +1607,7 @@ g_ptr_array_remove
|
|||||||
g_ptr_array_remove_index
|
g_ptr_array_remove_index
|
||||||
g_ptr_array_remove_fast
|
g_ptr_array_remove_fast
|
||||||
g_ptr_array_remove_index_fast
|
g_ptr_array_remove_index_fast
|
||||||
|
g_ptr_array_remove_range
|
||||||
g_ptr_array_sort
|
g_ptr_array_sort
|
||||||
g_ptr_array_sort_with_data
|
g_ptr_array_sort_with_data
|
||||||
g_ptr_array_set_size
|
g_ptr_array_set_size
|
||||||
@ -1624,6 +1626,7 @@ g_byte_array_append
|
|||||||
g_byte_array_prepend
|
g_byte_array_prepend
|
||||||
g_byte_array_remove_index
|
g_byte_array_remove_index
|
||||||
g_byte_array_remove_index_fast
|
g_byte_array_remove_index_fast
|
||||||
|
g_byte_array_remove_range
|
||||||
g_byte_array_sort
|
g_byte_array_sort
|
||||||
g_byte_array_sort_with_data
|
g_byte_array_sort_with_data
|
||||||
g_byte_array_set_size
|
g_byte_array_set_size
|
||||||
|
@ -212,9 +212,22 @@ g_array_remove_index().
|
|||||||
@Returns: the #GArray.
|
@Returns: the #GArray.
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION g_array_remove_range ##### -->
|
||||||
|
<para>
|
||||||
|
Removes the given number of elements starting at the given index from a
|
||||||
|
#GArray. The following elements are moved to close the gap.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@array: a @GArray.
|
||||||
|
@index_: the index of the first element to remove.
|
||||||
|
@length: the number of elements to remove.
|
||||||
|
@Returns: the #GArray.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION g_array_sort ##### -->
|
<!-- ##### FUNCTION g_array_sort ##### -->
|
||||||
<para>
|
<para>
|
||||||
Sorts a #GArray using @compare_func which should be a <function>qsort()</function>-style comparison
|
Sorts a #GArray using @compare_func which should be a qsort()-style comparison
|
||||||
function (returns -1 for first arg is less than second arg, 0 for equal, 1 if
|
function (returns -1 for first arg is less than second arg, 0 for equal, 1 if
|
||||||
first arg is greater than second arg).
|
first arg is greater than second arg).
|
||||||
</para>
|
</para>
|
||||||
|
@ -125,9 +125,22 @@ g_byte_array_remove_index().
|
|||||||
@Returns: the #GByteArray.
|
@Returns: the #GByteArray.
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION g_byte_array_remove_range ##### -->
|
||||||
|
<para>
|
||||||
|
Removes the given number of bytes starting at the given index from a
|
||||||
|
#GByteArray. The following elements are moved to close the gap.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@array: a @GByteArray.
|
||||||
|
@index_: the index of the first byte to remove.
|
||||||
|
@length: the number of bytes to remove.
|
||||||
|
@Returns: the #GByteArray.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION g_byte_array_sort ##### -->
|
<!-- ##### FUNCTION g_byte_array_sort ##### -->
|
||||||
<para>
|
<para>
|
||||||
Sorts a byte array, using @compare_func which should be a <function>qsort()</function>-style
|
Sorts a byte array, using @compare_func which should be a qsort()-style
|
||||||
comparison function (returns -1 for first arg is less than second arg, 0 for
|
comparison function (returns -1 for first arg is less than second arg, 0 for
|
||||||
equal, 1 if first arg is greater than second arg).
|
equal, 1 if first arg is greater than second arg).
|
||||||
</para>
|
</para>
|
||||||
|
@ -155,9 +155,21 @@ g_ptr_array_remove_index().
|
|||||||
@Returns: the pointer which was removed.
|
@Returns: the pointer which was removed.
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION g_ptr_array_remove_range ##### -->
|
||||||
|
<para>
|
||||||
|
Removes the given number of bytes starting at the given index from a
|
||||||
|
#GPtrArray. The following elements are moved to close the gap.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@array: a @GPtrArray.
|
||||||
|
@index_: the index of the first pointer to remove.
|
||||||
|
@length: the number of pointers to remove.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION g_ptr_array_sort ##### -->
|
<!-- ##### FUNCTION g_ptr_array_sort ##### -->
|
||||||
<para>
|
<para>
|
||||||
Sorts the array, using @compare_func which should be a <function>qsort()</function>-style comparison
|
Sorts the array, using @compare_func which should be a qsort()-style comparison
|
||||||
function (returns -1 for first arg is less than second arg, 0 for equal, 1 if
|
function (returns -1 for first arg is less than second arg, 0 for equal, 1 if
|
||||||
first arg is greater than second arg).
|
first arg is greater than second arg).
|
||||||
</para>
|
</para>
|
||||||
|
@ -267,6 +267,32 @@ g_array_remove_index_fast (GArray* farray,
|
|||||||
return farray;
|
return farray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GArray*
|
||||||
|
g_array_remove_range (GArray *farray,
|
||||||
|
guint index_,
|
||||||
|
guint length)
|
||||||
|
{
|
||||||
|
GRealArray *array = (GRealArray*) farray;
|
||||||
|
|
||||||
|
g_return_val_if_fail (array, NULL);
|
||||||
|
g_return_val_if_fail (index_ < array->len, NULL);
|
||||||
|
g_return_val_if_fail (index_ + length <= array->len, NULL);
|
||||||
|
|
||||||
|
if (index_ + length != array->len)
|
||||||
|
g_memmove (g_array_elt_pos (array, index_),
|
||||||
|
g_array_elt_pos (array, index_ + length),
|
||||||
|
(array->len - (index_ + length)) * array->elt_size);
|
||||||
|
|
||||||
|
array->len -= length;
|
||||||
|
#ifdef ENABLE_GC_FRIENDLY
|
||||||
|
g_array_elt_zero (array, array->len, length);
|
||||||
|
#else /* !ENABLE_GC_FRIENDLY */
|
||||||
|
g_array_zero_terminate (array);
|
||||||
|
#endif /* ENABLE_GC_FRIENDLY */
|
||||||
|
|
||||||
|
return farray;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
g_array_sort (GArray *farray,
|
g_array_sort (GArray *farray,
|
||||||
GCompareFunc compare_func)
|
GCompareFunc compare_func)
|
||||||
@ -414,7 +440,7 @@ g_ptr_array_maybe_expand (GRealPtrArray *array,
|
|||||||
#endif /* ENABLE_GC_FRIENDLY */
|
#endif /* ENABLE_GC_FRIENDLY */
|
||||||
array->alloc = g_nearest_pow (array->len + len);
|
array->alloc = g_nearest_pow (array->len + len);
|
||||||
array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
|
array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
|
||||||
array->pdata = g_realloc (array->pdata, sizeof(gpointer) * array->alloc);
|
array->pdata = g_realloc (array->pdata, sizeof (gpointer) * array->alloc);
|
||||||
#ifdef ENABLE_GC_FRIENDLY
|
#ifdef ENABLE_GC_FRIENDLY
|
||||||
for ( ; old_alloc < array->alloc; old_alloc++)
|
for ( ; old_alloc < array->alloc; old_alloc++)
|
||||||
array->pdata [old_alloc] = NULL;
|
array->pdata [old_alloc] = NULL;
|
||||||
@ -506,6 +532,28 @@ g_ptr_array_remove_index_fast (GPtrArray* farray,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
g_ptr_array_remove_range (GPtrArray* farray,
|
||||||
|
guint index_,
|
||||||
|
guint length)
|
||||||
|
{
|
||||||
|
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||||
|
|
||||||
|
g_return_if_fail (array);
|
||||||
|
g_return_if_fail (index_ < array->len);
|
||||||
|
g_return_if_fail (index_ + length <= array->len);
|
||||||
|
|
||||||
|
if (index_ + length != array->len)
|
||||||
|
g_memmove (&array->pdata[index_],
|
||||||
|
&array->pdata[index_ + length],
|
||||||
|
(array->len - (index_ + length)) * sizeof (gpointer));
|
||||||
|
|
||||||
|
array->len -= length;
|
||||||
|
#ifdef ENABLE_GC_FRIENDLY
|
||||||
|
g_array_elt_zero (array->pdata, array->len, length);
|
||||||
|
#endif /* ENABLE_GC_FRIENDLY */
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_ptr_array_remove (GPtrArray* farray,
|
g_ptr_array_remove (GPtrArray* farray,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -648,6 +696,18 @@ GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GByteArray*
|
||||||
|
g_byte_array_remove_range (GByteArray *array,
|
||||||
|
guint index_,
|
||||||
|
guint length)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (array, FALSE);
|
||||||
|
g_return_val_if_fail (index_ < array->len, FALSE);
|
||||||
|
g_return_val_if_fail (index_ + length <= array->len, FALSE);
|
||||||
|
|
||||||
|
return g_array_remove_range ((GArray*) array, index_, length);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
g_byte_array_sort (GByteArray *array,
|
g_byte_array_sort (GByteArray *array,
|
||||||
GCompareFunc compare_func)
|
GCompareFunc compare_func)
|
||||||
|
@ -88,6 +88,9 @@ GArray* g_array_remove_index (GArray *array,
|
|||||||
guint index_);
|
guint index_);
|
||||||
GArray* g_array_remove_index_fast (GArray *array,
|
GArray* g_array_remove_index_fast (GArray *array,
|
||||||
guint index_);
|
guint index_);
|
||||||
|
GArray* g_array_remove_range (GArray *array,
|
||||||
|
guint index_,
|
||||||
|
guint length);
|
||||||
void g_array_sort (GArray *array,
|
void g_array_sort (GArray *array,
|
||||||
GCompareFunc compare_func);
|
GCompareFunc compare_func);
|
||||||
void g_array_sort_with_data (GArray *array,
|
void g_array_sort_with_data (GArray *array,
|
||||||
@ -113,6 +116,9 @@ gboolean g_ptr_array_remove (GPtrArray *array,
|
|||||||
gpointer data);
|
gpointer data);
|
||||||
gboolean g_ptr_array_remove_fast (GPtrArray *array,
|
gboolean g_ptr_array_remove_fast (GPtrArray *array,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
void g_ptr_array_remove_range (GPtrArray *array,
|
||||||
|
guint index_,
|
||||||
|
guint length);
|
||||||
void g_ptr_array_add (GPtrArray *array,
|
void g_ptr_array_add (GPtrArray *array,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
void g_ptr_array_sort (GPtrArray *array,
|
void g_ptr_array_sort (GPtrArray *array,
|
||||||
@ -142,6 +148,9 @@ GByteArray* g_byte_array_remove_index (GByteArray *array,
|
|||||||
guint index_);
|
guint index_);
|
||||||
GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
|
GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
|
||||||
guint index_);
|
guint index_);
|
||||||
|
GByteArray* g_byte_array_remove_range (GByteArray *array,
|
||||||
|
guint index_,
|
||||||
|
guint length);
|
||||||
void g_byte_array_sort (GByteArray *array,
|
void g_byte_array_sort (GByteArray *array,
|
||||||
GCompareFunc compare_func);
|
GCompareFunc compare_func);
|
||||||
void g_byte_array_sort_with_data (GByteArray *array,
|
void g_byte_array_sort_with_data (GByteArray *array,
|
||||||
|
Loading…
Reference in New Issue
Block a user