From cc3f98e99cc505689973df614fe0d0bea981cf8b Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Wed, 14 May 2003 21:11:23 +0000 Subject: [PATCH] Added a removeItem method to the Array Ruamoko class. --- ruamoko/include/Array.h | 1 + ruamoko/lib/Array.r | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/ruamoko/include/Array.h b/ruamoko/include/Array.h index 54a49e0e6..9e82617ba 100644 --- a/ruamoko/include/Array.h +++ b/ruamoko/include/Array.h @@ -15,6 +15,7 @@ - (void []) getItemAt: (integer) index; - (void) setItemAt: (integer) index item:(void []) item; - (void) addItem: (void []) item; +- (void) removeItem: (void []) item; - (void []) removeItemAt: (integer) index; - (void []) insertItemAt: (integer) index item:(void []) item; - (integer) count; diff --git a/ruamoko/lib/Array.r b/ruamoko/lib/Array.r index 2408cd608..cbba2dc6a 100644 --- a/ruamoko/lib/Array.r +++ b/ruamoko/lib/Array.r @@ -53,6 +53,19 @@ array[count++] = item; } +- (void) removeItem: (void []) item +{ + local integer i, n; + + for (i = 0; i < count; i++) + if (array[i] == item) { + count--; + for (n = i; n < count; n++) + array[n] = array[n + 1]; + } + return; +} + - (void []) removeItemAt: (integer) index { local integer i;