12345678910111213141516171819202122232425262728 |
- namespace Invercargill {
- [GenericAccessors]
- public interface ReadOnlyAssociative<TKey, TValue> : Lot<KeyValuePair<TKey, TValue>> {
- public abstract bool try_get(TKey key, out TValue value);
- public abstract bool has(TKey key);
- public abstract Enumerable<TKey> keys { owned get; }
- public abstract Enumerable<TValue> values { owned get; }
- public virtual TValue @get(TKey key) throws IndexError {
- TValue value;
- if(try_get(key, out value)) {
- return value;
- }
- throw new IndexError.KEY_NOT_FOUND(@"Key not found in the associative collection");
- }
-
- public virtual TValue? get_or_default(TKey key) {
- TValue value;
- if(try_get(key, out value)) {
- return value;
- }
- return null;
- }
- }
- }
|