mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
Rualib: nuke some unnecessary classes
List, ListNode, and Stack aren't necessary; all three are obviated by the new, richer Array class.
This commit is contained in:
parent
b18302eac1
commit
82e934af47
8 changed files with 6 additions and 433 deletions
|
@ -1,26 +0,0 @@
|
|||
#ifndef __ruamoko_List_h
|
||||
#define __ruamoko_List_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
@interface List: Object
|
||||
{
|
||||
int count;
|
||||
struct list_bucket_s *head;
|
||||
struct list_bucket_s **tail;
|
||||
}
|
||||
- (id) init;
|
||||
- (id) getItemAt: (int) index;
|
||||
- (id) head;
|
||||
- (id) tail;
|
||||
- (void) addItemAtHead: (id) item;
|
||||
- (void) addItemAtTail: (id) item;
|
||||
- (id) removeItem: (id) item;
|
||||
- (id) removeItemAtHead;
|
||||
- (id) removeItemAtTail;
|
||||
- (int) count;
|
||||
-(void)makeObjectsPerformSelector:(SEL)selector;
|
||||
-(void)makeObjectsPerformSelector:(SEL)selector withObject:(id)arg;
|
||||
@end
|
||||
|
||||
#endif//__ruamoko_List_h
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
ListNode.h
|
||||
|
||||
Stack/Queue/Linked List node class definitions
|
||||
|
||||
Copyright (C) 2003 Jeff Teunissen <deek@quakeforge.net>
|
||||
|
||||
This file is part of the Ruamoko Standard Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
#ifndef __ruamoko_ListNode_h
|
||||
#define __ruamoko_ListNode_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
@interface ListNode: Object
|
||||
{
|
||||
ListNode *nextNode;
|
||||
id data;
|
||||
}
|
||||
|
||||
+ (id) nodeWithObject: (id)anObject;
|
||||
|
||||
- (id) initWithObject: (id)anObject;
|
||||
- (id) object;
|
||||
- (id) nextNode;
|
||||
- (void) setNextNode: (id)aNode;
|
||||
@end
|
||||
|
||||
#endif // __ruamoko_ListNode_h
|
|
@ -8,8 +8,8 @@ nobase_pkginclude_HEADERS= \
|
|||
draw.h key.h \
|
||||
\
|
||||
cbuf.h cmd.h cvar.h file.h gib.h hash.h plist.h runtime.h \
|
||||
AutoreleasePool.h Array.h Entity.h List.h ListNode.h Object.h \
|
||||
PropertyList.h Protocol.h Stack.h \
|
||||
Object.h Protocol.h \
|
||||
AutoreleasePool.h Array.h Entity.h PropertyList.h \
|
||||
\
|
||||
gui/Group.h gui/InputLine.h gui/Pic.h gui/Point.h gui/Rect.h gui/Size.h \
|
||||
gui/Slider.h gui/Text.h gui/View.h
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
Stack.h
|
||||
|
||||
Stack class definitions
|
||||
|
||||
Copyright (C) 2003 Jeff Teunissen <deek@quakeforge.net>
|
||||
|
||||
This file is part of the Ruamoko Standard Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
#ifndef __ruamoko_Stack_h
|
||||
#define __ruamoko_Stack_h
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
@interface Stack: Object
|
||||
{
|
||||
id top; // Top of the stack
|
||||
int stackSize;
|
||||
}
|
||||
|
||||
- (void) removeAllObjects; // Empty the stack
|
||||
- (void) addObject: (id)anObject; // Push anObject onto the stack
|
||||
- (id) pop; // pull top object off
|
||||
- (id) peek; // Grab the top object without removing it
|
||||
- (int) count; // Number of objects on stack
|
||||
|
||||
@end
|
||||
|
||||
#endif // __ruamoko_Stack_h
|
|
@ -1,152 +0,0 @@
|
|||
#include "List.h"
|
||||
|
||||
struct list_bucket_s {
|
||||
struct list_bucket_s *next;
|
||||
struct list_bucket_s **prev;
|
||||
id obj;
|
||||
};
|
||||
typedef struct list_bucket_s list_bucket_t;
|
||||
|
||||
@implementation List
|
||||
|
||||
- (id) init
|
||||
{
|
||||
count = 0;
|
||||
head = nil;
|
||||
tail = &head;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
local list_bucket_t *e, *t = nil; //FIXME t uninitialized
|
||||
|
||||
for (e = head; e; e = t) {
|
||||
t = e.next;
|
||||
[e.obj release];
|
||||
obj_free (e);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) getItemAt: (int) index
|
||||
{
|
||||
local list_bucket_t *e;
|
||||
if (index < 0 || index >= count)
|
||||
return nil;
|
||||
for (e = head; e && index; index--)
|
||||
e = e.next;
|
||||
return e.obj;
|
||||
}
|
||||
|
||||
-(id) head
|
||||
{
|
||||
if (!head)
|
||||
return nil;
|
||||
return head.obj;
|
||||
}
|
||||
|
||||
-(id) tail
|
||||
{
|
||||
local list_bucket_t *e = (list_bucket_t *) tail;
|
||||
if (!e)
|
||||
return nil;
|
||||
return e.obj;
|
||||
}
|
||||
|
||||
-(void) addItemAtHead: (id) item
|
||||
{
|
||||
local list_bucket_t *e = obj_malloc (@sizeof (list_bucket_t));
|
||||
e.obj = item;
|
||||
e.next = head;
|
||||
e.prev = &head;
|
||||
if (head)
|
||||
head.prev = &e.next;
|
||||
head = e;
|
||||
count++;
|
||||
}
|
||||
|
||||
-(void) addItemAtTail: (id) item
|
||||
{
|
||||
local list_bucket_t *e = obj_malloc (@sizeof (list_bucket_t));
|
||||
e.obj = item;
|
||||
e.next = nil;
|
||||
e.prev = tail;
|
||||
tail[0] = e;
|
||||
tail = &e.next;
|
||||
count++;
|
||||
}
|
||||
|
||||
- (id) removeItem: (id) item
|
||||
{
|
||||
local list_bucket_t *e;
|
||||
|
||||
for (e = head; e; e = e.next) {
|
||||
if (e.obj == item) {
|
||||
e.prev[0] = e.next;
|
||||
if (e.next)
|
||||
e.next.prev = e.prev;
|
||||
obj_free (e);
|
||||
count--;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) removeItemAtHead
|
||||
{
|
||||
local list_bucket_t *e;
|
||||
local id obj;
|
||||
|
||||
if (!count)
|
||||
return nil;
|
||||
e = head;
|
||||
obj = e.obj;
|
||||
e.prev[0] = e.next;
|
||||
if (e.next)
|
||||
e.next.prev = e.prev;
|
||||
if (tail == &e.next)
|
||||
tail = e.prev;
|
||||
obj_free (e);
|
||||
count--;
|
||||
return obj;
|
||||
}
|
||||
|
||||
- (id) removeItemAtTail
|
||||
{
|
||||
local list_bucket_t *e;
|
||||
local id obj;
|
||||
|
||||
if (!count)
|
||||
return nil;
|
||||
e = (list_bucket_t *) tail;
|
||||
obj = e.obj;
|
||||
e.prev[0] = e.next;
|
||||
if (e.next)
|
||||
e.next.prev = e.prev;
|
||||
obj_free (e);
|
||||
count--;
|
||||
return obj;
|
||||
}
|
||||
|
||||
- (int) count
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
-(void)makeObjectsPerformSelector:(SEL)selector
|
||||
{
|
||||
local list_bucket_t *e;
|
||||
for (e = head; e; e = e.next)
|
||||
[e.obj performSelector:selector];
|
||||
}
|
||||
|
||||
-(void)makeObjectsPerformSelector:(SEL)selector withObject:(id)arg
|
||||
{
|
||||
local list_bucket_t *e;
|
||||
for (e = head; e; e = e.next)
|
||||
[e.obj performSelector:selector withObject:arg];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
ListNode.h
|
||||
|
||||
Stack/Queue/Linked List node class definitions
|
||||
|
||||
Copyright (C) 2003 Jeff Teunissen <deek@quakeforge.net>
|
||||
|
||||
This file is part of the Ruamoko Standard Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "Object.h"
|
||||
#include "ListNode.h"
|
||||
|
||||
@implementation ListNode
|
||||
|
||||
+ (id) nodeWithObject: (id)anObject
|
||||
{
|
||||
return [[[self alloc] initWithObject: anObject] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithObject: (id)anObject
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
||||
data = [anObject retain];
|
||||
nextNode = nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[data release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) nextNode
|
||||
{
|
||||
return nextNode;
|
||||
}
|
||||
|
||||
- (void) setNextNode: (id)aNode
|
||||
{
|
||||
nextNode = aNode;
|
||||
}
|
||||
|
||||
- (id) object
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
@end
|
|
@ -30,10 +30,10 @@ EXTRA_LIBRARIES= $(ruamoko_libs)
|
|||
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -c -o $@ $<
|
||||
|
||||
libr_a_SOURCES=\
|
||||
cbuf.r cmd.r cvar.r file.r hash.r plist.r qfile.r qfs.r script.r sound.r \
|
||||
string.r \
|
||||
AutoreleasePool.r Array.r Array+Private.r Entity.r List.r ListNode.r Object.r \
|
||||
PropertyList.r Protocol.r Stack.r
|
||||
cbuf.r cmd.r cvar.r file.r hash.r plist.r qfile.r qfs.r script.r \
|
||||
sound.r string.r \
|
||||
Object.r Protocol.r \
|
||||
AutoreleasePool.r Array.r Array+Private.r Entity.r PropertyList.r
|
||||
libr_a_AR=$(PAK) -cf
|
||||
|
||||
libqw_a_SOURCES=\
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
Stack.r
|
||||
|
||||
A general-purpose stack class
|
||||
|
||||
Copyright (C) 2003 Jeff Teunissen <deek@quakeforge.net>
|
||||
|
||||
This file is part of the Ruamoko Standard Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "Object.h"
|
||||
#include "ListNode.h"
|
||||
#include "Stack.h"
|
||||
|
||||
@implementation Stack
|
||||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
while ([self count] > 0)
|
||||
[self pop];
|
||||
}
|
||||
|
||||
- (void) addObject: (id)anObject
|
||||
{
|
||||
local id oldTop = top;
|
||||
top = [[ListNode alloc] initWithObject: anObject];
|
||||
[top setNextNode: oldTop];
|
||||
stackSize++;
|
||||
}
|
||||
|
||||
- (id) pop
|
||||
{
|
||||
local id data;
|
||||
local id oldTop = nil;
|
||||
|
||||
if (!top)
|
||||
return nil;
|
||||
|
||||
oldTop = top;
|
||||
top = [top nextNode];
|
||||
stackSize--;
|
||||
|
||||
data = [[oldTop object] retain];
|
||||
[oldTop release];
|
||||
|
||||
return [data autorelease];
|
||||
}
|
||||
|
||||
- (id) peek
|
||||
{
|
||||
return [top object];
|
||||
}
|
||||
|
||||
- (int) count
|
||||
{
|
||||
return stackSize;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue