Hi, I would like to have some recommendation on my software design. I'm having a data structure fixed with 10 elements to store incoming messages. Whenever a massage is received, it would be stored into that data structure. The messages come with content and priority and subpriority levels
Rules
------
1) When the data structure is full (all 10 filled), the new message will overwrite the element in the data structure with lowest priority, and also with priority lower than the incoming message. If all elements are having higher priority, the message will be discarded.
2) If the incoming massage having same priority with the lowest priority element in the data structure, subpriority will be compared and the (1) will be executed again.
I'm thinking of creating a new priority queue array, storing indices and priority info to my data structure, with sorting algo to arrange the array according to priority. Whenever a new message arrives, it will look into the bottom of the arrays for comparison, then gradually move up the queue and repeat (1) & (2).
I've got a feeling that this might not be an efficient implementation. I would be thankful if you could suggest a better way...