From eb5a7b794289683fe1dac9ad32f850d82b207d8f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 3 Jul 2010 23:39:06 +0200 Subject: [PATCH] Remove unused source files. --- src/CHashtable.cpp | 291 --------------------------------------------- src/CHashtable.h | 64 ---------- src/CReference.cpp | 30 ----- src/CReference.h | 30 ----- src/CString.cpp | 177 --------------------------- src/CString.h | 48 -------- 6 files changed, 640 deletions(-) delete mode 100644 src/CHashtable.cpp delete mode 100755 src/CHashtable.h delete mode 100644 src/CReference.cpp delete mode 100755 src/CReference.h delete mode 100644 src/CString.cpp delete mode 100755 src/CString.h diff --git a/src/CHashtable.cpp b/src/CHashtable.cpp deleted file mode 100644 index e9560fd..0000000 --- a/src/CHashtable.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* -Copyright (C) 2005 Parallel Realities - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "headers.h" - -Hashtable::Hashtable() -{ - for (int i = 0 ; i < MAX_BUCKETS ; i++) - { - bucket[i] = NULL; - } - - nullWarning = true; - - name = "Unnamed Hashtable"; -} - -Hashtable::~Hashtable() -{ - clear(); -} - -void Hashtable::put(char *key, void *data) -{ - unsigned int hash = 0; - unsigned int entryBucket = 0; - - for (unsigned int i = 0 ; i < strlen(key) ; i++) - { - hash = hash * MULTIPLIER + key[i]; - } - - entryBucket = hash % MAX_BUCKETS; - - Entry *entry; - - if (bucket[entryBucket] == NULL) - { - entry = new Entry(); - entry->hash = hash; - entry->data = data; - entry->previous = NULL; - entry->next = NULL; - - bucket[entryBucket] = entry; - - //printf("Added %s = (Hash = %d : Bucket = %d (1))\n", key, hash, entryBucket); - } - else - { - Entry *last = bucket[entryBucket]; - int count = 1; - - while (true) - { - count++; - - // already added! - if (last->hash == hash) - { - debug(("WARNING - POSSIBLE HASHCODE COLLISION!! - %s\n", key)); - return; - } - - if (last->next != NULL) - { - last = last->next; - } - else - { - break; - } - } - - entry = new Entry(); - entry->hash = hash; - entry->data = data; - entry->previous = last; - entry->next = NULL; - - last->next = entry; - - //printf("Added %s = (Hash = %d : Bucket = %d (%d))\n", key, hash, entryBucket, count); - } -} - -void *Hashtable::get(char *key) -{ - unsigned int hash = 0; - unsigned int entryBucket = 0; - - for (unsigned int i = 0 ; i < strlen(key) ; i++) - { - hash = hash * MULTIPLIER + key[i]; - } - - entryBucket = hash % MAX_BUCKETS; - - Entry *entry = bucket[entryBucket]; - - while (entry != NULL) - { - if (entry->hash == hash) - { - return entry->data; - } - - entry = entry->next; - } - - if (nullWarning) - { - printf("WARNING - Hashtable::get('%s') - Returning NULL!\n", key); - } - - return NULL; -} - -void Hashtable::remove(char *key) -{ - unsigned int hash = 0; - unsigned int entryBucket = 0; - - for (unsigned int i = 0 ; i < strlen(key) ; i++) - { - hash = hash * MULTIPLIER + key[i]; - } - - entryBucket = hash % MAX_BUCKETS; - - Entry *entry = bucket[entryBucket]; - - while (entry != NULL) - { - if (entry->hash == hash) - { - if (entry->previous != NULL) - { - entry->previous->next = entry->next; - } - - if (entry->next != NULL) - { - entry->next->previous = entry->previous; - } - - free(entry->data); - - delete entry; - - if (entry == bucket[entryBucket]) - { - bucket[entryBucket] = NULL; - } - - return; - } - - entry = entry->next; - } -} - -int Hashtable::getSize() -{ - int count = 0; - Entry *entry; - - for (int i = 0 ; i < MAX_BUCKETS ; i++) - { - if (bucket[i] != NULL) - { - count++; - - entry = bucket[i]->next; - - while (entry != NULL) - { - count++; - - entry = entry->next; - } - } - } - - return count; -} - -List *Hashtable::toList() -{ - list.clear(); - - Entry *entry; - Reference *ref; - - for (int i = 0 ; i < MAX_BUCKETS ; i++) - { - if (bucket[i] != NULL) - { - ref = new Reference(); - ref->object = (GameObject*)bucket[i]->data; - list.add(ref); - - entry = bucket[i]->next; - - while (entry != NULL) - { - ref = new Reference(); - ref->object = (GameObject*)entry->data; - list.add(ref); - - entry = entry->next; - } - } - } - - return &list; -} - -void Hashtable::printTable() -{ - int count = 0; - Entry *entry; - - for (int i = 0 ; i < MAX_BUCKETS ; i++) - { - if (bucket[i] != NULL) - { - count++; - - printf("%.3d = %d", i, bucket[i]->hash); - - entry = bucket[i]->next; - - while (entry != NULL) - { - count++; - - printf(", %d", entry->hash); - - entry = entry->next; - } - - printf("\n"); - } - } - - printf("%d entries in table\n", count); -} - -void Hashtable::clear() -{ - Entry *entry = NULL; - Entry *entry2 = NULL; - - int count = 0; - - for (int i = 0 ; i < MAX_BUCKETS ; i++) - { - for (entry = bucket[i] ; entry != NULL ; entry = entry2) - { - entry2 = entry->next; - free(entry->data); - delete entry; - count++; - } - - bucket[i] = NULL; - } - - if ((count > 0) && (nullWarning)) - { - debug(("Removed %d items from %s Hashtable\n", count, name.getText())); - } -} diff --git a/src/CHashtable.h b/src/CHashtable.h deleted file mode 100755 index a01d41a..0000000 --- a/src/CHashtable.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright (C) 2005 Parallel Realities - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#define MULTIPLIER 65599 -#define MAX_BUCKETS 256 - -class Hashtable { - - private: - - struct Entry { - - unsigned int hash; - - void *data; - - Entry *previous; - Entry *next; - - }; - - Entry *bucket[MAX_BUCKETS]; - - List list; - - public: - - bool nullWarning; - - String name; - - Hashtable(); - ~Hashtable(); - - void put(char *key, void *data); - void *get(char *key); - void remove(char *key); - - List *toList(); - - int getSize(); - - void clear(); - - void printTable(); - -}; diff --git a/src/CReference.cpp b/src/CReference.cpp deleted file mode 100644 index dae2cda..0000000 --- a/src/CReference.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (C) 2005 Parallel Realities - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "headers.h" - -Reference::Reference() -{ - object = NULL; -} - -Reference::~Reference() -{ -} diff --git a/src/CReference.h b/src/CReference.h deleted file mode 100755 index aa75731..0000000 --- a/src/CReference.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (C) 2005 Parallel Realities - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -class Reference : public GameObject { - - public: - - GameObject *object; - - Reference(); - ~Reference(); - -}; diff --git a/src/CString.cpp b/src/CString.cpp deleted file mode 100644 index bc70827..0000000 --- a/src/CString.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* -Copyright (C) 2005 Parallel Realities - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "headers.h" - -String::String() -{ - setText(""); -} - -String::String(char *text) -{ - int size = strlen(text); - - this->text = new char[size + 1]; - - strncpy(this->text, text, sizeof this->text); - - this->length = size; -} - -String::~String() -{ - if (this->text != NULL) - { - delete[] this->text; - this->text = NULL; - } -} - -/* -Got this off Google... not sure I entirely trust it but it seems -to be okay. -*/ -void String::trim() -{ - if (text == NULL) - { - return; - } - - char *tempText = new char[length + 1]; - - char *c = text; - - while (*c == ' ') - { - c++; // LOL!!! :) - } - - strncpy(tempText, c, sizeof tempText); - - int len = strlen(tempText); - - while ((len > 0) && ((tempText[len - 1] == ' ') || (tempText[len - 1] == '\0'))) - { - tempText[--len] = 0; - } - - delete[] this->text; - - this->text = tempText; -} - -void String::operator= (char *text) -{ - if (this->text != NULL) - { - delete[] this->text; - this->text = NULL; - } - - if (text == NULL) - { - printf("WARNING: String - Can't set NULL!\n"); - return; - } - - int size = strlen(text); - - this->text = new char[size + 1]; - - strncpy(this->text, text, sizeof this->text); - - this->length = size; -} - -bool String::operator== (char *text) -{ - if (strcmp(this->text, text) == 0) - { - return true; - } - - return false; -} - -bool String::operator== (String string) -{ - if (strcmp(this->text, string.getText()) == 0) - { - return true; - } - - return false; -} - -bool String::operator!= (char *text) -{ - if (strcmp(this->text, text) != 0) - { - return true; - } - - return false; -} - -bool String::operator!= (String string) -{ - if (strcmp(this->text, string.getText()) != 0) - { - return true; - } - - return false; -} - -void String::setText(char *text, ...) -{ - tmpString[0] = 0; - - va_list argp; - va_start(argp, text); - vsnprintf(tmpString, sizeof tmpString, text, argp); - va_end(argp); - - int size = strlen(tmpString); - - this->text = new char[size + 1]; - - strncpy(this->text, tmpString, sizeof this->text); -} - -char *String::getText() -{ - if (text == NULL) - { - printf("WARNING: String::getText() - text is NULL!\n"); - return NULL; - } - - return text; -} - -int String::getLength() -{ - return length; -} - -char String::tmpString[1024]; diff --git a/src/CString.h b/src/CString.h deleted file mode 100755 index b56f229..0000000 --- a/src/CString.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright (C) 2005 Parallel Realities - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -class String { - - private: - - char *text; - int length; - - static char tmpString[1024]; - - public: - - String(); - String(char *text); - ~String(); - - void trim(); - - void operator= (char *text); - bool operator== (char *text); - bool operator== (String string); - bool operator!= (char *text); - bool operator!= (String string); - - void setText(char *text, ...); - char *getText(); - int getLength(); - -}; -- 2.39.5