public T Search(ICountable <T> array, T item) { var arr = array.GetEnumerable().OrderBy(x => x).ToList(); var lower = 0; var upper = arr.Count - 1; var mid = -1; while (lower < upper) { mid = lower + (upper - lower) / (Math.Abs(arr[upper].GetHashCode()) - Math.Abs(arr[lower].GetHashCode())) * (Math.Abs(item.GetHashCode()) - Math.Abs(arr[lower].GetHashCode())); if (arr[mid].CompareTo(item) < 0) { lower = mid + 1; } else if (arr[mid].CompareTo(item) > 0) { upper = mid - 1; } else { return(arr[mid]); } } if (lower == upper && arr[lower].CompareTo(item) == 0) { return(arr[lower]); } return(default(T)); }
public ICountable <T> Sort(ICountable <T> array) { var arr = (ICountable <T>)array.Clone(); var gap = arr.Count / 2; while (gap > 0) { for (var i = 0; i + gap < arr.Count; i++) { var j = i + gap; var tmp = arr[j]; while (j - gap >= 0 && tmp.CompareTo(arr[j - gap]) < 0) { arr[j] = arr[j - gap]; j -= gap; } arr[j] = tmp; } gap /= 2; } return(arr); }
public static void Count(ICountable c, int maxCount) { for (int i = 0; i < maxCount; i++) { c.IncrementCount(); Console.WriteLine($"{c.GetCountString()}"); } }
public static void Count(ICountable c, int MaxCount) { while (c.GetCount() <= MaxCount) { Console.WriteLine(c.GetCountString() + " " + c.Name); c.IncrementCount(); } }
public static void count(ICountable c, int maxCount) { for (int i = 0; i < maxCount; i++) { c.incrementCount(); Console.WriteLine(c.getCountString() + " " + c.GetType().ToString().Split('.')[1]); } }
public static void Count(ICountable c, int MaxCount) { Console.WriteLine(""); for (; c.GetCount() <= MaxCount; c.IncrementCount()) { Console.WriteLine(c.ToString()); } c.ResetCount(); }
public static CountCommand Count(this ICountable countable) { var countCommand = new CountCommand(countable.Client) { ParentSelector = countable }; return(countCommand); }
public static void Count(ICountable c, int maxCount) { for (int i = 1; i <= maxCount; i++) { c.IncrementCount(); Console.WriteLine(c.GetCountString() + " " + c.Name + "\n"); } c.ResetCount(); }
public static void Count(ICountable c, int maxCount) {//counts up to the specified max and prints each count while (c.GetCount() < maxCount) { c.IncrementCount(); c.FormatCount(); Thread.Sleep(500); } Console.WriteLine(); }
public void Count(ICountable c, int MaxCount) { Console.WriteLine($"Counting {c.GetType().Name}s:\n"); for (int i = 0; i < MaxCount; i++) { c.IncrementCount(); Console.WriteLine($"{c.GetCount()}. {c.ReturnName()}"); } c.ResetCount(); Console.WriteLine(""); }
public T Search(ICountable <T> array, T item) { for (var i = 0; i < array.Count; i++) { if (array[i].Equals(item)) { return(array[i]); } } return(default(T)); }
private void IncrementCreatedInstanceCount(ICountable instance) { var className = instance.GetType().Name; if (!CreatedInstancesCount.ContainsKey(className)) { CreatedInstancesCount.Add(className, new List <ICountable>()); } CreatedInstancesCount[className].Add(instance); }
public static void Count(ICountable c, int maxCount) { //use while to count the number of Countable objects while (maxCount != 0) { c.IncrementCount(); Console.WriteLine(c.GetCountString()); maxCount--; } Console.WriteLine(); //reset the count c.ResetCount(); }
public static void Count(ICountable e, int MaxCount) { int delay = 1000; for (int i = 0; i < MaxCount; i++) { e.IncrementCount(); Console.WriteLine(e.GetCountString()); Thread.Sleep(delay); } CountChuckle.AhAhAh(); Console.WriteLine(" "); }
public CountableExample(ICountable <T> countable, T searchItem, T containsItem, T indexOfItem, T lastIndexOfItem, int setIndex, T setValue, int getIndex, Action beforeStep = null, Action afterStep = null) { _searchItem = searchItem; Countable = countable; _containsItem = containsItem; _indexOfItem = indexOfItem; _lastIndexOfItem = lastIndexOfItem; _setIndex = setIndex; _setValue = setValue; _getIndex = getIndex; BeforeStep = beforeStep; AfterStep = afterStep; }
/// <summary> /// Initializes a new instance of the <see cref="CountStream"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="location">The location.</param> public CountStream(CountStreamType type, string location) { m_type = type; m_location = location; switch (type) { case CountStreamType.Directory: m_first = new CountableDirectory(location); break; case CountStreamType.VSSolution2005: m_first = new DotNetSolution(location); break; default: throw new NotImplementedException(); } }
/// <summary> /// Reads this instance. /// </summary> /// <returns></returns> public override ICountable Read() { if (m_finished) { return(null); } // If current is NULL, then this is the first ICountable to read if (m_current == null) { m_current = m_first; m_currentChildIndex = -1; m_stack.Push(new Pair <ICountable, int>(m_current, 0)); } // If the current index is -1, we return the current item and // increment the current child index if (m_currentChildIndex == -1) { m_currentChildIndex++; return(m_current); } // Check if we have read all children, recursively while (m_current.Children.Count == 0 || m_current.Children.Count == m_currentChildIndex) { Pair <ICountable, int> last = m_stack.Pop(); m_current = last.First; m_currentChildIndex = last.Second; if (m_current == m_first && m_current.Children.Count == m_currentChildIndex) { m_finished = true; return(null); } } ICountable result = m_current.Children[m_currentChildIndex]; m_stack.Push(new Pair <ICountable, int>(m_current, m_currentChildIndex + 1)); m_currentChildIndex = 0; m_current = result; return(result); }
/// <summary> /// Reads this instance. /// </summary> /// <returns></returns> public override ICountable Read() { if (m_finished) { return null; } // If current is NULL, then this is the first ICountable to read if (m_current == null) { m_current = m_first; m_currentChildIndex = -1; m_stack.Push(new Pair<ICountable, int>(m_current, 0)); } // If the current index is -1, we return the current item and // increment the current child index if (m_currentChildIndex == -1) { m_currentChildIndex++; return m_current; } // Check if we have read all children, recursively while (m_current.Children.Count == 0 || m_current.Children.Count == m_currentChildIndex) { Pair<ICountable, int> last = m_stack.Pop(); m_current = last.First; m_currentChildIndex = last.Second; if (m_current == m_first && m_current.Children.Count == m_currentChildIndex) { m_finished = true; return null; } } ICountable result = m_current.Children[m_currentChildIndex]; m_stack.Push(new Pair<ICountable, int>(m_current, m_currentChildIndex + 1)); m_currentChildIndex = 0; m_current = result; return result; }
public ICountable <T> Sort(ICountable <T> array) { var arr = (ICountable <T>)array.Clone(); for (var i = 0; i < arr.Count - 1; i++) { for (var j = 0; j < arr.Count - 1; j++) { if (arr[j].CompareTo(arr[j + 1]) > 0) { var tmp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = tmp; } } } return(arr); }
public ICountable <T> Sort(ICountable <T> array) { var arr = (ICountable <T>)array.Clone(); for (var i = 1; i < arr.Count; i++) { var insert = arr[i]; var pos = i; while (pos > 0 && arr[pos - 1].CompareTo(insert) > 0) { arr[pos] = arr[pos - 1]; pos--; } arr[pos] = insert; } return(arr); }
public ICountable <T> Sort(ICountable <T> array) { var arr = (ICountable <T>)array.Clone(); for (var i = 0; i < arr.Count - 1; i++) { var min = i; for (var j = i + 1; j < arr.Count; j++) { if (arr[j].CompareTo(arr[min]) < 0) { min = j; } } var tmp = arr[i]; arr[i] = arr[min]; arr[min] = tmp; } return(arr); }
public IEnumerator Setup() { var scene = SceneManager.LoadSceneAsync("CollisionPlayerController"); while (!scene.isDone) { yield return(null); } sut = GameObject.FindGameObjectWithTag("Player"); Assert.That(sut != null, "There must be tagged player in the scene"); Assert.That(sut.transform.position, Is.EqualTo(Vector3.zero), "Player shoudl be at the center of the scene"); var rigidbody = sut.GetComponent <Rigidbody>(); Assert.That(rigidbody != null, "Player must have a rigidbody component"); Assert.That(rigidbody.useGravity, Is.False, "Player must not be using gravity"); var collider = sut.GetComponent <Collider>(); Assert.That(collider != null, "Player must have a collider"); Assert.That(collider.isTrigger, Is.True, "Player must have a triggerable collider"); audio = sut.GetComponent <AudioSourceMockController>(); Assert.That(audio != null, "The player must have audio mock"); var text = GameObject.Find("DisplayManager"); Assert.That(text != null, "There should be a display available"); display = text.GetComponent <TextMeshProUGUI>(); Assert.That(display != null, "There must be text in the display"); Assert.That(display.text, Is.EqualTo("0"), "Display should be zero"); counter = sut.GetComponent <ICountable>(); Assert.That(counter != null, "The player must be countable"); Assert.That(counter.Count, Is.EqualTo(0), "Counter must start at zero"); }
public DeadLetterTestProcessor(ICountable countable) { _countable = countable; }
public DiTestCommandHandler(ICountable countable) { _countable = countable; }
static int CountItem(int total, ICountable item) { total += item.Count(); return(total); }
public ArrayExample(ICountable <int> array) : base(array, 5, 8, 13, 13, 1, 21, 2, FirstInit, SecondInit) { _array = array; }
public HomeController(ICountable countPlz) { this.countPlz = countPlz; }
public MultipleCommandProcessor(ICountable countable) { _countable = countable; }
public EventProcessor(ICountable countable) { _countable = countable; }
public SagaDuplicateWithDuplicate(ICountable countable, bool throwOnProcess = false) { _countable = countable; _throwOnProcess = throwOnProcess; MessageMapper.MapStartMessage <SagaStartMessage>(m => "b"); }
public NumberCounterController(ICountable countable) { numberCounter = countable; }