コード例 #1
0
        public void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            // Remove last old data posted in previous post
            if (lastOldData != null) {
                for (var i = 0; i < lastOldData.Length; i++) {
                    PriorEventMap.Remove(lastOldData[i]);
                }
            }

            // Post new data to rolling buffer starting with the oldest
            if (newData != null) {
                for (var i = 0; i < newData.Length; i++) {
                    var newEvent = newData[i];

                    // Add new event
                    NewEvents.Add(newEvent);

                    // Save prior index events in array
                    var priorEvents = new EventBean[priorToIndexesSize];
                    for (var j = 0; j < priorToIndexesSize; j++) {
                        var priorIndex = priorToIndexes[j];
                        priorEvents[j] = NewEvents.Get(priorIndex);
                    }

                    PriorEventMap.Put(newEvent, priorEvents);
                }
            }

            // Save old data to be removed next time we get posted results
            lastOldData = oldData;
        }
コード例 #2
0
        public EventBean GetRelativeToEvent(
            EventBean theEvent,
            int priorToIndex)
        {
            if (priorToIndex >= priorToIndexesSize) {
                throw new ArgumentException(
                    "Index " + priorToIndex + " not allowed, max size is " + priorToIndexesSize);
            }

            var priorEvents = PriorEventMap.Get(theEvent);
            if (priorEvents == null) {
                throw new IllegalStateException("Event not currently in collection, event=" + theEvent);
            }

            return priorEvents[priorToIndex];
        }