public void associationsDo(FuncNs.Func <AssociationType, Object> enumerator1) { foreach (var kvp in bindings) { enumerator1(kvp.Value); } }
public virtual void keysAndValuesDo(FuncNs.Func <KeyType, ValueType, Object> enumerator2) { foreach (var kvp in bindings) { AssociationType association = kvp.Value; enumerator2(association.Key, association.Value); } }
public virtual void valuesDo(FuncNs.Func <ValueType, Object> enumerator1) { foreach (var kvp in bindings) { AssociationType association = kvp.Value; enumerator1(association.Value); } }
public void keysDo(FuncNs.Func <KeyType, Object> enumerator1) { foreach (var kvp in bindings) { AssociationType association = kvp.Value; enumerator1(association.Key); } }
public virtual AssociationType associationAtIfAbsent(KeyType key, FuncNs.Func <AssociationType> notFoundAction) { AssociationType association; if (bindings.TryGetValue(key, out association)) { return(association); } return(notFoundAction == null ? null : notFoundAction()); }
public ValueType atIfAbsentPut(KeyType key, FuncNs.Func <ValueType> computeValueToBeAdded) { return(atIfAbsent( key, delegate() { ValueType value = computeValueToBeAdded(); AssociationType association = newAssociation(key, value); association.keyBeImmutable(); bindings[key] = association; return value; })); }
public Object removeKeyIfAbsent(KeyType key, FuncNs.Func <Object> notFoundAction) { AssociationType association; if (bindings.TryGetValue(key, out association)) { if (!association.IsDeletable) { throw new PrimNonDeletableKeyException("The association with the key " + key.ToString() + " is not removable from the KeyedCollection."); } bindings.Remove(key); return(association.Value); } else if (notFoundAction == null) { return(null); } else { return(notFoundAction()); } }
public static String[] elementsFromStream(this TextReader stream, char[] separatorChars, FuncNs.Func <Object, Object> transformer) { if (separatorChars == null || separatorChars.Length < 1) { var value = stream.nextWhile(ch => true); return(new String[] { transformer == null ? value : (String)transformer(value) }); } if (separatorChars.Length < 2) { return(elementsFromStream(stream, separatorChars[0], transformer)); } List <String> segments = new List <string>(); StringBuilder segment = new StringBuilder(); while (true) { int next = stream.Peek(); while (next != -1 && Array.FindIndex <char>(separatorChars, ch => ch == next) < 0) { segment.Append((char)stream.Read()); next = stream.Peek(); } String element = transformer == null?segment.ToString() : (String)transformer(segment.ToString()); if (!String.IsNullOrEmpty(element)) { segments.Add(element); } if (next == -1) { return(segments.ToArray()); } segment = new StringBuilder(); // Should be segment.Clear(), but that's not supported in .Net 3.5 stream.Read(); } }
public static String[] elementsFromString(this String pathString, char[] separatorChars, FuncNs.Func <Object, Object> transformer) { return(elementsFromStream(new StringReader(pathString), separatorChars, transformer)); }
public static String[] elementsFromStream(this TextReader stream, char separatorChar, FuncNs.Func <Object, Object> transformer) { List <String> segments = new List <string>(); StringBuilder segment = new StringBuilder(); while (true) { int next = stream.Peek(); while (next != -1 && next != separatorChar) { segment.Append((char)stream.Read()); next = stream.Peek(); } String element = transformer == null?segment.ToString() : (String)transformer(segment.ToString()); if (!String.IsNullOrEmpty(element)) { segments.Add(element); } if (next == -1) { return(segments.ToArray()); } segment = new StringBuilder(); // Should be segment.Clear(), but that's not supported in .Net 3.5 stream.Read(); } }
public Object _keysAndValuesDo_(Object receiver, Object enumerator2) { FuncNs.Func <Object, Object, Object> f2 = asFunctor2(enumerator2); ((ESIdentityDictionary)receiver).keysAndValuesDo((key, value) => f2(key, value)); return(receiver); }
public Object _valuesDo_(Object receiver, Object enumerator1) { FuncNs.Func <Object, Object> f1 = asFunctor1(enumerator1); ((ESIdentityDictionary)receiver).valuesDo(key => f1(key)); return(receiver); }
public Object _associationsDo_(Object receiver, Object enumerator1) { FuncNs.Func <Object, Object> f1 = asFunctor1(enumerator1); ((ESIdentityDictionary)receiver).associationsDo(association => f1(association)); return(receiver); }
public virtual ValueType atIfAbsent(KeyType key, FuncNs.Func <ValueType> notFoundAction) { var association = associationAtIfAbsent(key, null); return(association == null ? (notFoundAction == null ? null : notFoundAction()) : association.Value); }