subclassing lists?
- From: Dirk Luetjens <dirk post lfm rwth-aachen de>
- To: gnome-list gnome org
- Subject: subclassing lists?
- Date: Thu, 25 Jun 1998 20:38:58 +0200 (CEST)
Hello,
here comes the last question in the field of programming techniques. This
is more a GTK+ question, but Iīm not subscribed to the list. And I know
that this group has the world best programmers :-)
I wanted to model a line of points in a line class wich is a subclass of a
list. In the sence of C++
class Line : GList
{
int Length;
}
I tried to follow the object oriented approach int C using the syntax from
GTK+ and GNOME. The problem was, that I canīt subclass the GList struct,
since it does not have a control element. GLists are used in the form:
Glist *list = NULL;
list = g_list_append (list, pointer);
This results in the following :
list -> {GList}
|
{GList}
|
{GList}
|
NULL
To be able to subclass, I must have an element of GList in the beginning
of the struct, and not only the pointer. But that would mean, that I
always have an unused element in the list:
struct _Line {
GList list;
int length;
}
A better solution would be a control element:
struct _GListNode {
gpointer data;
GListNode next;
GListNode prev;
}
struct _GList {
GListNode first;
GListNode last;
}
graphically:
list -> {GList} -> {GListNode}
| |
| {GListNode}
| |
\-----> {GListNode}
|
-
So my question: What is the reason for the other implementation and why
does the object oriented idea from GTK+ is not implemented in the glib.
Or did I miss some significant point?
Dirk
_/ _/_/ _/ _/ Dirk Luetjens
_/ _/ _/_/ _/_/ Lehrstuhl fuer Messtechnik
_/ _/_/ _/ _/ _/ RWTH Aachen
_/ _/ _/ _/ D-52056 Aachen
_/_/_/_/ _/ _/ _/ Germany
Institute for Measurement Techniques phone: +49 241 80 78 65
University of Technology Aachen fax: 8888 200
email: dirk@post.LfM.RWTH-Aachen.De
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]