Help with 'self maintaining' array?

Hi all,
I am running into a brain freeze in my implementation of what I'd call a 'self maintaining' array. The purpose is I have a China import 24" LED sign (non-Betabrite) for which I I was able to map out the control codes used to program it. I want to have a WiFly enabled Arduino listening for incoming connections from our Nagios systems monitoring and scroll the events on the sign. I want the Arduino to keep track of N number of events since the events coming from Nagios are single shots (e.g. I don't want to have a script on a PC keep track of N number of events and simply push a list of them to the Arduino; I want the events to come in individually, and the Arduino auto-rotate out first-in events or remove events from memory if a packet instructs it to).

What I am trying to do is:
For each message received via WiFly over tcp to the arduino {

  1. Receive a string via WiFly that is delimited (e.g. "1111|C|myhost.internet.com|Is not responding to PING|RED,BLINK")
  2. Break it out via the '|' delimiter
  3. Parse out fields 2,5 to expand into output-device specific control codes
  4. Create a keypair association with field 1 as the key and a combination of the specific control codes + the remaining fields in the string (e.g. 1111 -> ~128~B\a\Y1myhost.internet.com Is not responding to PING').
  5. If MAXLINES (e.g. max number of items to retain) is exceeded, delete the earliest one
    }
    I can do 1-3 fairly easily, but am having problems with #4.

If(field 2 == 'D'){

  1. Find the keypair referenced by field 1
  2. Delete it
    }

For each key-pair {

  1. Extract each kayvalue and append it to a larger String
    }; Send this String to the sign

I have tried using the HashMap library, it is seemed initially to do what I wanted, but have a weird problem where if I call the function containing the hashMap[hashpos](hID, hMessage) function, it seems to overwrite all previous hashMap entries.
Simplified code example:

void run(void){
InitHash();
hID="1234";
hMessage="www.internet1.com is DOWN";
AddToArray();

hID="2345";
hMessage="www2.internet2.com is UP";
AddToArray();
}

void InitHash(){
for(int n=0; n< HASH_SIZE; n++){
hashMapn;
}
}

void AddToArray(){
// Find the first open slot
hashpos=hashMap.getIndexOf("-1");
if(hashpos < HASH_SIZE){
hashMap[hashpos](hID, hMessage);
} else {
Serial.println("No room in hash");
}
}

When run (considering proper variables et all), I get:
hashMap during first pass:
1234 - www.internet1.com is DOWN
-1 - -1
-1 - -1

hashMap during second pass:
2345 - www2.internet2.com is UP
2345 - www2.internet2.com is UP
-1 - -1

For every subsequent time AddToHash() is called, it seems to be filling in hashMap[0] through hashMap[index of first found '-1'] with the string, overwriting previous entries.

I have looked into using a queue or list, but those didn't seem a good fit. I also tried DB and EDB, but they seemed to lack a delete function, so I'd have to manually save off the DB content into memory and reconstruct/compress when deleting. Lastly, I looked at using eeprom as storage, but am concerned about the write lifetime and again, easy management of the data.

Any ideas or pointers to code that can work like a database? Sorry this is so long of a post.

I would create a class to hold a single event and keep them in a linked list (essentially a dynamic Queue).

As a part of your class object, create a member function to compare it as needed.

Once you start thinking of each event as a single object, it will start to seem a lot easier.

Careful with memory usage here, especially when you start talking about "append it to a larger string".

Some class methods you'd want as examples:

<new event received>
EventList.push(new EventObj( id, hostName, event, severity, alertType ) );

<to delete a specific event>
EventList.delete( id, hostname, event );

<to delete oldest>
EventList.pop();

<to update an event>
EventObj* event = EventList.find(id, hostname, event);
if (event)
{
 event->severity = newSeverity;
}

<to update sign>
Serial.print( EventList.BuildOutputString() );

Obviously that's all just hand-waiving for the most part, and you'd need to create all of those functions - none of them are built in. But that would be the general concept if you want code that is very easy to debug, maintain, and update in the future.

However, if you're new to C++, the above is a significant undertaking. especially with the limited debugging available for arduino.

If it was me, I'd build the classes in C++ as a console application first for debugging purposes, then port it to arduino.