public override bool MoveNext() { for (int i = this.indices.Length - 1; i >= 0; i--) { if (this.indices[i] < this.Domains[i].Count - 1) { // updating index this.indices[i]++; // reseting the other to zero for(int j = i+1 ; j < this.indices.Length;++j) this.indices[j] = 0; // getting the tuple tuple = new Tuple(); for (int k = 0; k < this.indices.Length; ++k) { object item = this.Domains[k][this.indices[k]]; tuple.Add(item); } return true; } } return false; }
public override void Reset() { for (int i = 0; i < this.indices.Length; ++i) { if (i==this.indices.Length-1) this.indices[i] = -1; else this.indices[i] = 0; } this.tuple=null; }
private static void Write(ITuple tuple) { foreach (var item in tuple.Values) { Console.WriteLine(item); } for (int i = 0; i < tuple.Count; i++) { Console.WriteLine(tuple[i]); } }
public int CompareTo(ITuple tuple) { if (((object)tuple) == null) return -1; if (this.Count < tuple.Count) return -1; else if (this.Count > tuple.Count) return 1; for (int i = 0; i < this.Count; ++i) { int c = Comparer.Default.Compare(this[i], tuple[i]); if (c != 0) return c; } return 0; }
public void Concat(ITuple tuple) { foreach (Object o in tuple) this.Add(o); }
public TupleRunInvoker( IRun generator, MethodInfo method, ITuple tupleDomains, ITuple tuple) : base(generator) { this.method = method; this.tupleDomains = tupleDomains; this.tuple = tuple; }
public static bool IsSingleton(this ITuple tuple) { return(tuple != null && tuple.Count == 1); }
/// <summary>Execute a lambda Function with the content of this tuple</summary> /// <param name="tuple">Tuple of size 2</param> /// <param name="lambda">Function that will be passed the content of this tuple as parameters</param> /// <returns>Result of calling <paramref name="lambda"/> with the items of this tuple</returns> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static TResult With <T1, T2, TResult>([NotNull] this ITuple tuple, [NotNull] Func <T1, T2, TResult> lambda) { OfSize(tuple, 2); return(lambda(tuple.Get <T1>(0), tuple.Get <T2>(1))); }
/// <summary>Execute a lambda Action with the content of this tuple</summary> /// <param name="tuple">Tuple of size 8</param> /// <param name="lambda">Action that will be passed the content of this tuple as parameters</param> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static void With <T1, T2, T3, T4, T5, T6, T7, T8>([NotNull] this ITuple tuple, [NotNull] Action <T1, T2, T3, T4, T5, T6, T7, T8> lambda) { OfSize(tuple, 8); lambda(tuple.Get <T1>(0), tuple.Get <T2>(1), tuple.Get <T3>(2), tuple.Get <T4>(3), tuple.Get <T5>(4), tuple.Get <T6>(5), tuple.Get <T7>(6), tuple.Get <T8>(7)); }
/// <summary>Execute a lambda Action with the content of this tuple</summary> /// <param name="tuple">Tuple of size 5</param> /// <param name="lambda">Action that will be passed the content of this tuple as parameters</param> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static void With <T1, T2, T3, T4, T5>([NotNull] this ITuple tuple, [NotNull] Action <T1, T2, T3, T4, T5> lambda) { OfSize(tuple, 5); lambda(tuple.Get <T1>(0), tuple.Get <T2>(1), tuple.Get <T3>(2), tuple.Get <T4>(3), tuple.Get <T5>(4)); }
/// <summary>Execute a lambda Action with the content of this tuple</summary> /// <param name="tuple">Tuple of size 1</param> /// <param name="lambda">Action that will be passed the content of this tuple as parameters</param> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static void With <T1>([NotNull] this ITuple tuple, [NotNull] Action <T1> lambda) { OfSize(tuple, 1); lambda(tuple.Get <T1>(0)); }
public bool Equals(ITuple other) => Equality.CombineAll(this, other);
public bool Equals(ITuple other) { return(!object.ReferenceEquals(other, null) && ((IStructuralEquatable)this).Equals(other, SimilarValueComparer.Default)); }
public ITuple Concat([NotNull] ITuple tuple) { return(STuple.Concat(this, tuple)); }
/// <summary> /// Initializes a new instance of the <c>BindingErrorEventArgs</c> class. /// </summary> /// <param name="exception">Exception related to the event.</param> /// <param name="expression">Binding expression related to the event.</param> /// <param name="tuple">Tuple related to the event.</param> public BindingErrorEventArgs(Exception exception, Expression expression, ITuple tuple) : base(exception) { _tuple = tuple; Expression = expression; }
public void AddS(ITuple tuple) { //throw new NotImplementedException(); }
//----------------------------------------------------------------------------- //-------------------------------- TUPLE SPACE SPECIFIC FUNCTIONS ---------------------- public void Add(ITuple tuple) { this.node.TupleSpace.Add(tuple); List <Entry> l = new List <Entry>(); lock (this.leaderLog) { l.Add(new Entry("add", tuple, this.term, this.leaderLog.CommitIndex)); this.leaderLog.CommitIndex++; this.leaderLog.AppendNewEntries(l); } if (DF.N == 1) { return; } bool allAck = false; int consensus = 0; Dictionary <int, bool> alreadyTried = new Dictionary <int, bool>(DF.N); for (int i = 0; i < DF.N; i++) { alreadyTried[i] = false; } while (!allAck) { List <IAsyncResult> results = new List <IAsyncResult>(); List <WaitHandle> waits = new List <WaitHandle>(); View v = this.node.manager.RequestView(); foreach (KeyValuePair <int, Pingable> entry in v.pingables) { if (!alreadyTried[entry.Key]) { AppendEntriesMessage message = new AppendEntriesMessage(this.term, 0, 0, this.leaderLog.CommitIndex, l, entry.Key, node.url); RemoteAsyncCallAppendEntryDelegate RemoteDel = new RemoteAsyncCallAppendEntryDelegate(node.otherNodes[entry.Key].AppendEntry); IAsyncResult RemAr = RemoteDel.BeginInvoke(message, null, null); results.Add(RemAr); waits.Add(RemAr.AsyncWaitHandle); } } allAck = WaitHandle.WaitAll(waits.ToArray(), DF.TIMEOUT);//Change to a more reliable value because of timeouts if (!allAck) { for (int i = 0; i < waits.Count; i++) { try { if (waits[i].WaitOne(0)) { RemoteAsyncCallAppendEntryDelegate d = (RemoteAsyncCallAppendEntryDelegate)((AsyncResult)results[i]).AsyncDelegate; ResponseMessage r = d.EndInvoke(results[i]); if (r.Success && !alreadyTried[r.SharedId]) { //leaderLog.FollowersCommitIndex[r.SharedId]++; alreadyTried[r.SharedId] = true; consensus++; } } }catch (Exception ex) { } if (consensus > DF.N / 2) { allAck = true; } } } } foreach (KeyValuePair <int, bool> entry in alreadyTried) { if (entry.Value) { leaderLog.FollowersCommitIndex[entry.Key]++; } } return; }
public void RaiseLhsExpressionFailed(ISession session, Exception exception, Expression expression, object[] arguments, ITuple tuple, IFact fact, NodeDebugInfo nodeInfo, ref bool isHandled) { var handler = LhsExpressionFailedEvent; if (handler != null) { var @event = new LhsExpressionErrorEventArgs(expression, exception, arguments, tuple, fact, nodeInfo.Rules); handler(session, @event); isHandled |= @event.IsHandled; } _parent?.RaiseLhsExpressionFailed(session, exception, expression, arguments, tuple, fact, nodeInfo, ref isHandled); }
public void RaiseLhsExpressionEvaluated(ISession session, Exception exception, Expression expression, object[] arguments, object result, ITuple tuple, IFact fact, NodeDebugInfo nodeInfo) { var handler = LhsExpressionEvaluatedEvent; if (handler != null) { var @event = new LhsExpressionEventArgs(expression, exception, arguments, result, tuple, fact, nodeInfo.Rules); handler(session, @event); } _parent?.RaiseLhsExpressionEvaluated(session, exception, expression, arguments, result, tuple, fact, nodeInfo); }
/// <summary>Returns a typed version of a tuple of size 1</summary> /// <typeparam name="T1">Expected type of the single element</typeparam> /// <param name="tuple">Tuple that must be of size 1</param> /// <returns>Equivalent tuple, with its element converted to the specified type</returns> public static STuple <T1> As <T1>([NotNull] this ITuple tuple) { tuple.OfSize(1); return(new STuple <T1>(tuple.Get <T1>(0))); }
/// <summary> /// 指定されたタプルを内容とするパラメータ値を返します。 /// </summary> /// <returns>パラメータ値</returns> /// <param name="tuple">タプル</param> public static IParameterValue OfValue(ITuple tuple) { return(new TupleParameterValue(tuple)); }
/// <summary>Execute a lambda Action with the content of this tuple</summary> /// <param name="tuple">Tuple of size 3</param> /// <param name="lambda">Action that will be passed the content of this tuple as parameters</param> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static void With <T1, T2, T3>([NotNull] this ITuple tuple, [NotNull] Action <T1, T2, T3> lambda) { OfSize(tuple, 3); lambda(tuple.Get <T1>(0), tuple.Get <T2>(1), tuple.Get <T3>(2)); }
TupleParameterValue(ITuple tuple) { UnitdefUtil.ArgumentMustNotBeNull(tuple, "tuple"); TupleValue = tuple; Type = ParameterValueType.Tuple; }
public static bool IsNullOrEmpty(this ITuple tuple) { return(tuple == null || tuple.Count == 0); }
public Task Insert(SessionContext context, ITuple tuple, T fact) { return(TaskUtil.Completed); }
/// <summary>Execute a lambda Function with the content of this tuple</summary> /// <param name="tuple">Tuple of size 1</param> /// <param name="lambda">Action that will be passed the content of this tuple as parameters</param> /// <returns>Result of calling <paramref name="lambda"/> with the items of this tuple</returns> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static TResult With <T1, TResult>([NotNull] this ITuple tuple, [NotNull] Func <T1, TResult> lambda) { return(lambda(tuple.OfSize(1).Get <T1>(0))); }
private static TGrouping Create(string pattern, Func <IList <QueueItem>, ITuple <QueueItem, int> > addFunc) => ITuple.Create(pattern, addFunc);
/// <summary>Execute a lambda Function with the content of this tuple</summary> /// <param name="tuple">Tuple of size 5</param> /// <param name="lambda">Function that will be passed the content of this tuple as parameters</param> /// <returns>Result of calling <paramref name="lambda"/> with the items of this tuple</returns> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static TResult With <T1, T2, T3, T4, T5, TResult>([NotNull] this ITuple tuple, [NotNull] Func <T1, T2, T3, T4, T5, TResult> lambda) { OfSize(tuple, 5); return(lambda(tuple.Get <T1>(0), tuple.Get <T2>(1), tuple.Get <T3>(2), tuple.Get <T4>(3), tuple.Get <T5>(4))); }
public static T Last <T>([NotNull] this ITuple tuple) { return(tuple.Get <T>(-1)); }
/// <summary>Execute a lambda Function with the content of this tuple</summary> /// <param name="tuple">Tuple of size 8</param> /// <param name="lambda">Function that will be passed the content of this tuple as parameters</param> /// <returns>Result of calling <paramref name="lambda"/> with the items of this tuple</returns> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static TResult With <T1, T2, T3, T4, T5, T6, T7, T8, TResult>([NotNull] this ITuple tuple, [NotNull] Func <T1, T2, T3, T4, T5, T6, T7, T8, TResult> lambda) { OfSize(tuple, 8); return(lambda(tuple.Get <T1>(0), tuple.Get <T2>(1), tuple.Get <T3>(2), tuple.Get <T4>(3), tuple.Get <T5>(4), tuple.Get <T6>(5), tuple.Get <T7>(6), tuple.Get <T8>(7))); }
private IEnumerable <T> EnumerateSphere(ITuple center, double distance, bool tHemisphere) { Node[] stack; int sp; int i; Leaf leaf; double distance2 = distance * distance; double[] centerValues = new double[dimMax]; for (int dim = dimMax; --dim >= 0;) { centerValues[dim] = center.GetDimValue(dim); } stack = new Node[StackDepth]; sp = 0; IElement ele = eleRoot; while (ele is Node) { Node node = (Node)ele; if (center.GetDimValue(node.dim) - distance <= node.splitValue) { if (sp == StackDepth) { throw new ApplicationException("Bspt.EnumerateSphere tree stack overflow"); } stack[sp++] = node; ele = node.eleLE; } else { ele = node.eleGE; } } leaf = (Leaf)ele; i = 0; while (true) { for (; i < leaf.count; ++i) { var lt = leaf.tuples[i]; var distT = lt.GetDimValue(0) - centerValues[0]; if (tHemisphere && distT < 0) { goto Break_Widthin; } double dist2 = distT * distT; if (dist2 > distance2) { goto Break_Widthin; } for (int dim = dimMax; --dim > 0;) { distT = lt.GetDimValue(dim) - centerValues[dim]; dist2 += distT * distT; if (dist2 > distance2) { goto Break_Widthin; } } var ret = leaf.tuples[i++]; ret.Distance2 = dist2; yield return(ret); goto continue_while; Break_Widthin: ; } if (sp == 0) { yield break; } ele = stack[--sp]; while (ele is Node) { Node node = (Node)ele; if (center.GetDimValue(node.dim) + distance < node.splitValue) { if (sp == 0) { yield break; } ele = stack[--sp]; } else { ele = node.eleGE; while (ele is Node) { Node nodeLeft = (Node)ele; stack[sp++] = nodeLeft; ele = nodeLeft.eleLE; } } } leaf = (Leaf)ele; i = 0; continue_while: ; } }
public IEnumerable <T> EnumerateHemiSphere(ITuple center, double distance) { return(EnumerateSphere(center, distance, true)); }
public static ITuple Substring([NotNull] this ITuple tuple, int offset) { Contract.NotNull(tuple, nameof(tuple)); return(tuple[offset, null]); }
public static ITuple Append <T1, T2>([NotNull] this ITuple tuple, T1 value1, T2 value2) { Contract.NotNull(tuple, nameof(tuple)); return(new JoinedTuple(tuple, STuple.Create(value1, value2))); }
public bool Equals(ITuple value) { return(value != null && value.Count == 0); }
public static ITuple Append <T1, T2, T3, T4>([NotNull] this ITuple tuple, T1 value1, T2 value2, T3 value3, T4 value4) { Contract.NotNull(tuple, nameof(tuple)); return(new JoinedTuple(tuple, STuple.Create <T1, T2, T3, T4>(value1, value2, value3, value4))); }
public CombinatorialMethodTestCase( string fixtureName, MethodInfo method, ITuple tupleDomains, ITuple tuple ) : base(fixtureName, method) { if (tupleDomains == null) throw new ArgumentNullException("tupleDomains"); if (tuple == null) throw new ArgumentNullException("tuple"); this.tupleDomains = tupleDomains; this.tuple = tuple; foreach (Object parameter in tuple) this.Parameters.Add(new TestCaseParameter(parameter)); }