/// <summary> /// If the provided order book entry exists in the price level a /// <code>MamdaOrderBookException</code> exception is thrown. Otherwise the /// method simply returns. /// </summary> /// <param name="entry">The entry whose presence in the level is being determined.</param> /// <exception cref="MamdaOrderBookException">Throws MamdaOrderBookException if the entry is found in the price</exception> public void checkNotExist(MamdaOrderBookEntry entry) { for (int i = 0; i < mEntries.Count; i++) { MamdaOrderBookEntry existingEntry = (MamdaOrderBookEntry)mEntries[i]; if (existingEntry.equalId(entry.getId())) { throw new MamdaOrderBookException( "attempted to add am existent entry: " + entry.getId()); } } }
private int findEntryAfter( ArrayList entries, int start, string id) { int i; int size = entries.Count; for (i = start; i < size; i++) { MamdaOrderBookEntry entry = (MamdaOrderBookEntry)entries[i]; if (entry.equalId(id)) { return(i); } } return(i); }
/// <summary> /// Remove an order book entry from the price level. /// <see cref="MamdaOrderBookEntry"/> /// </summary> /// <param name="entry">The entry which is to be removed from the price level.</param> public void removeEntry(MamdaOrderBookEntry entry) { for (int i = 0; i < mEntries.Count; i++) { MamdaOrderBookEntry existingEntry = (MamdaOrderBookEntry)mEntries[i]; if (existingEntry.equalId(entry.getId())) { mEntries.RemoveAt(i); return; } } if (mStrictChecking) { throw new MamdaOrderBookException( "attempted to delete a non-existent entry: " + entry.getId()); } }
/// <summary> /// Update the details of an existing entry in the level. /// </summary> /// <param name="entry">An instance of <code>MamdaOrderBookEntry</code> with the /// new details for the entry in the level.</param> public void updateEntry(MamdaOrderBookEntry entry) { for (int i = 0; i < mEntries.Count; i++) { MamdaOrderBookEntry existingEntry = (MamdaOrderBookEntry)mEntries[i]; if (existingEntry.equalId(entry.getId())) { existingEntry.setDetails(entry); return; } } if (mStrictChecking) { throw new MamdaOrderBookException( "attempted to update a non-existent entry: " + entry.getId()); } }