public void FoldR4() { var list = FList.New(1, 2, 4, 8, 16); int actual = FList.FoldR((agg, input) => agg / input, 1, list); Assert.AreEqual(4, actual); }
public void FoldL2() { var list = FList.New(1, 2, 4, 8, 16); int actual = FList.FoldL((agg, input) => agg * input, 1, list); Assert.AreEqual(1024, actual); }
public void FoldR3() { var list = FList.New(1, 2, 4, 8, 16); int actual = FList.FoldR((agg, input) => agg - input, 0, list); Assert.AreEqual(11, actual); }
public void Any4() { var list = FList.New(3); var any = FList.Any(i => i > 3, list); Assert.IsFalse(any); }
public void Any1String() { var list = "123"; var any = FList.Any(i => i > '1', list); Assert.IsTrue(any); }
public Gamepad(IntPtr pmJoystick) { pName= "Unknown Gamepad"; pJoystick= pmJoystick; if(Sdl.SDL_JoystickIsHaptic(pJoystick)== 1) pHaptic= Sdl.SDL_HapticOpenFromJoystick(pJoystick); else pHaptic= IntPtr.Zero; bRumble= (Sdl.SDL_HapticRumbleSupported(pHaptic)== Sdl.SDL_TRUE); if(bRumble) bRumble= (Sdl.SDL_HapticRumbleInit(pHaptic)== 0); if(bRumble) Console.WriteLine("HAPTIC_RUMBLE SUPPORTED"); buttons= new FList<GamepadButton>(); dpads= new FList<GamepadDpad>(); sticks= new FList<GamepadStick>(); buttonsHeld= GBL.NONE; for(int i= 0; i< Sdl.SDL_JoystickNumButtons(pJoystick); i++) buttons.add(new GamepadButton(pJoystick, i)); for(int i= 0; i< Sdl.SDL_JoystickNumHats(pJoystick); i++) dpads.add(new GamepadDpad(pJoystick, i)); for(int i= 0; i< (int)(Sdl.SDL_JoystickNumAxes(joystick)/2f); i++) { if(mapStick(Sdl.SDL_JoystickGetAxis(joystick, i*2))== -1) { triggers.add(new GamepadTrigger(joystick, i*2)); triggers.add(new GamepadTrigger(joystick, (i*2)+1)); } else sticks.add(new GamepadStick(pJoystick, i*2, (i*2)+1)); } }
internal void DeleteAndNotDestroy(int index) { T r = FList[index]; OnDelete(r, index); FList.RemoveAt(index); }
public void NewWithHeadAndNullNullableType() { var list = FList.New <string>(null, "a", "b"); Assert.IsFalse(FList.IsEmpty(list)); Assert.AreEqual(", a, b", list.ToString()); }
private static void GetILOffsets(APC pc, Method method, out int primaryILOffset, out int methodILOffset) { primaryILOffset = pc.ILOffset; if (pc.Block.Subroutine.IsMethod) { methodILOffset = 0; return; } // look through context FList <STuple <CFGBlock, CFGBlock, string> > context = pc.SubroutineContext; while (context != null) { if (context.Head.One.Subroutine.IsMethod) { string topLabel = context.Head.Three; if (topLabel == "exit" || topLabel == "entry" || topLabel.StartsWith("after")) { CFGBlock fromBlock = context.Head.One; methodILOffset = fromBlock.ILOffset(fromBlock.PriorLast); } else { CFGBlock toBlock = context.Head.Two; methodILOffset = toBlock.ILOffset(toBlock.First); } return; } context = context.Tail; } methodILOffset = primaryILOffset; }
public void NewHeadOnly() { var list = FList.New(1); Assert.IsFalse(FList.IsEmpty(list)); Assert.AreEqual("1", list.ToString()); }
public void NewWithHeadAndNull() { var list = FList.New(3, null); Assert.IsFalse(FList.IsEmpty(list)); Assert.AreEqual("3", list.ToString()); }
protected GUIContainer() : base() { components= new FList<GUIComponent>(); focusedComp= null; pSprite= null; }
public void FoldL5() { var list = FList.New <int>(1, 2, 4, 8, 16); string actual = FList.FoldL <int, string>((agg, input) => agg + input.ToString(), "", list); Assert.AreEqual("168421", actual); }
public void FoldL4() { var list = FList.New <float>(1, 2, 4, 8, 16); float actual = FList.FoldL <float, float>((agg, input) => agg / input, 1, list); Assert.AreEqual(9.765625e-4, actual); }
public void FoldR5() { var list = FList.New <int>(1, 2, 4, 8, 16); string actual = FList.FoldR <int, string>((input, agg) => agg + input.ToString(), "", list); Assert.AreEqual("124816", actual); }
internal PluginManager(string relativePath) { pPlugins= new FList<IPlugin>();; tags= new string[]{"addon"}; bInit= new bool[8]; defaultPath= relativePath; }
public void FoldR1String() { var list = "abcde"; int actual = FList.FoldR((agg, input) => agg + Convert.ToInt32(input), 0, list); Assert.AreEqual(495, actual); }
void Update() { if (Input.GetKeyUp(KeyCode.Space)) { replace.GetComponentInChildren <ParticleSystem>().Stop(); GetComponentInChildren <ParticleSystem>().Play(); _currentSpeed = speed; _timer = timeToExplode; transform.position = _startPos; _allParticles.Select(x => x.main).Aggregate(FList.Create <ParticleSystem.MainModule>(), (acum, current) => { current.loop = true; return(acum + current); }); } _timer -= Time.deltaTime; if (_timer <= 0.0f) { GetComponentInChildren <ParticleSystem>().Stop(); } transform.position += transform.forward * _currentSpeed * Time.deltaTime; }
public BaseClousotWorker(IWorkerId id, FList <string> baseArgs, IScheduler scheduler) : base(id, scheduler) { Contract.Requires(id != null); this.baseArgs = baseArgs; }
public void Head2() { var list = FList.New(5); var actual = FList.Head(list); var expected = 5; Assert.AreEqual(expected, actual); }
public void Any3() { var list = FList.New(3); var any = FList.Any(i => i > 2, list); Assert.IsTrue(any); }
public void Head1String() { var list = "12345"; var actual = FList.Head(list); var expected = '1'; Assert.AreEqual(expected, actual); }
public void Any5() { var list = FList.Empty <int>(); var any = FList.Any(i => i > 3, list); Assert.IsFalse(any); }
public void Head1() { var list = FList.New(1, 2, 3, 4, 5); var actual = FList.Head(list); var expected = 1; Assert.AreEqual(expected, actual); }
public void Any2String() { var list = "123"; var any = FList.Any(i => i > '3', list); Assert.IsFalse(any); }
public void Elem1String() { var list = "12345"; var actual = FList.Elem('3', list); var expected = true; Assert.AreEqual(expected, actual); }
public void Elem1() { var list = FList.New(1, 2, 3, 4, 5); var actual = FList.Elem(3, list); var expected = true; Assert.AreEqual(expected, actual); }
public void SortBy1() { var list = FList.New(7, 1, 4, 6, 3, 2, 5); var actual = FList.SortBy((x, y) => x < y, list); var expected = FList.New(1, 2, 3, 4, 5, 6, 7); Assert.AreEqual(expected, actual); }
public void Elem5() { var list = FList.New(5); var actual = FList.Elem(6, list); var expected = false; Assert.AreEqual(expected, actual); }
public void Elem3String() { var list = "12345"; var actual = FList.Elem('6', list); var expected = false; Assert.AreEqual(expected, actual); }
public void Elem4() { var list = FList.New(5); var actual = FList.Elem(5, list); var expected = true; Assert.AreEqual(expected, actual); }
public void SortBy7() //Test for stability { var list = FList.New("Adi", "Ali", "Amy", "Max", "Zoe"); var actual = FList.SortBy((x, y) => x[0] < y[0], list); var expected = FList.New("Adi", "Ali", "Amy", "Max", "Zoe"); Assert.AreEqual(expected, actual); }
public void Elem6() { var list = FList.Empty <int>(); var actual = FList.Elem(6, list); var expected = false; Assert.AreEqual(expected, actual); }
protected GUIContainer() : base() { components= new FList<GUIComponent>(); focusedComp= null; bEComponents= false; e_components= null; }
internal KeyboardHelper(Viewport pmViewport) { keysHeld= new FList<KKL>(); keyProc= new FList<int> ( (int)KKL.LEFT, (int)KKL.UP, (int)KKL.RIGHT, (int)KKL.DOWN, (int)KKL.LEFT_ALT, (int)KKL.LEFT_CTRL, (int)KKL.LEFT_SHIFT, (int)KKL.RIGHT_ALT, (int)KKL.RIGHT_CTRL, (int)KKL.RIGHT_SHIFT, (int)KKL.TAB ); viewport= pmViewport; viewport.KeyDown+= onKeyDown; viewport.KeyUp+= onKeyUp; }
Update next; // during reversal public static Update Reverse(FList updates, FList common) { Update oldest = null; while (updates != common) { Update current = (Update)updates.Head; current.next = oldest; oldest = current; updates = updates.Tail; } return oldest; }
private void AddUpdate(Update upd) { Debug.Assert(!this.IsConstant, "modification of locked down egraph"); this.updates = FList.Cons(upd, this.updates); }
/// <summary> /// Copy constructor /// </summary> /// <param name="from"></param> private EGraph(EGraph from, CfgBlock at) { this.constRoot = from.constRoot; this.termMap = from.termMap; this.idCounter = from.idCounter; this.absMap = from.absMap; this.elementLattice = from.elementLattice; this.forwMap = from.forwMap; this.eqTermMap = from.eqTermMap; // keep history this.updates = from.updates; this.parent = from; this.root = from.root; this.historySize = from.historySize+1; this.Block = at; // set from to constant from.constant = true; }
public EGraph(MathematicalLattice elementLattice) { this.elementLattice = elementLattice; this.constRoot = FreshSymbolicValue(); this.termMap = DoubleFunctionalMap.Empty; this.absMap = FunctionalMap.Empty; this.forwMap = FunctionalMap.Empty; this.eqTermMap = DoubleFunctionalMap.Empty; this.constant = false; this.parent = null; this.root = this; this.historySize = 1; this.updates = null; }
public static FList Append(FList l1, FList l2) { if (l1 == null) return l2; if (l2 == null) return l1; return FList.Cons(l1.elem, Append(l1.tail, l2)); }
public static int Length(FList l) { if (l == null) { return 0; } else return l.count; }
internal AudioPlayer(Game pmGame) { pMasterVolume= 1f; game= pmGame; channels= new FList<int>(); }
// Cel-Shades the given model public void celshadeRange(FList<Model> models) { for(int i= 0; i< models.size; i++) models[i].celshade(ref currTextureID); }
public FList(object elem, FList tail) { this.elem = elem; this.tail = tail; this.count = FList.Length(tail) + 1; }
public static bool Contains(FList l, object o) { if (l==null) return false; if (Equals(l.elem, o)) return true; return Contains(l.tail, o); }
public bool MoveNext() { if (beforefirst) { this.beforefirst = false; this.rest = this.first; return (rest != null); } if (rest != null) { rest = rest.Tail; return (rest != null); } return false; }
public FListEnumerator(FList first) { this.first = first; beforefirst = true; }
public static FList Reverse(FList list) { FList tail = null; while (list != null) { tail = FList.Cons(list.elem, tail); list = list.tail; } return tail; }
private void Replay(FList updates, FList common) { // First reverse updates. Update oldest = Update.Reverse(updates, common); while (oldest != null) { oldest.Replay(this); oldest = oldest.Next; } }
public string ToIndent() { Action<Node> na; Action<List<Node>> nsa = null; const string ind = " "; FList<string> inds = new FList<string>(); StringBuilder b = new StringBuilder(); na = delegate(Node n) { if (n.Leaf != null) { b .Append(inds.Deriv(Cty.ToLine)) .Append(n.Leaf) .AppendLine(); } else if (n.Branches != null) { if (n != this) inds.Add(ind); nsa(n.Branches); if (n != this) inds.RemoveAt(inds.Count - 1); } }; nsa = delegate(List<Node> ns) { if (ns.Count == 0) return; bool isPrevBranch = ns[0].Branches != null; na(ns[0]); for (int i = 1; i < ns.Count; i++) { if (isPrevBranch && ns[i].Branches != null) { b .Append(inds.Deriv(Cty.ToLine)) .Append(ind) .AppendLine(); } isPrevBranch = ns[i].Branches != null; na(ns[i]); } }; na(this); return b.ToString(); }
private static void Partition(FList l, object pivot, out FList less, out FList more) { less = null; more = null; if (l == null) { return; } foreach(object value in l) { if (System.Collections.Comparer.Default.Compare(value, pivot) <= 0) { less = FList.Cons(value, less); } else { more = FList.Cons(value, more); } } }
/// <summary> /// Given two sorted lists, compute their intersection /// </summary> /// <param name="l1">sorted list</param> /// <param name="l2">sorted list</param> /// <returns>sorted intersection</returns> public static FList Intersect(FList l1, FList l2) { if (l1 == null || l2 == null) return null; int comp = System.Collections.Comparer.Default.Compare(l1.Head, l2.Head); if (comp < 0) { return Intersect(l1.Tail, l2); } if (comp > 0) { return Intersect(l1, l2.Tail); } // equal return FList.Cons(l1.Head, Intersect(l1.Tail, l2.Tail)); }
public static FList Cons(object elem, FList rest) { return new FList(elem, rest); }
public static FList Sort(FList l) { return Sort(l, null); }
public static FList Sort(FList l, FList tail) { // quicksort if (l == null) return tail; object pivot = l.Head; FList less; FList more; Partition(l.Tail, pivot, out less, out more); return Sort(less, FList.Cons(pivot, Sort(more, tail))); }
public Spline() { points= new FList<Point3f>(); segmentSize= 0; }
// Initiates the input internal static void init(Game pmGame) { game= pmGame; Sdl.SDL_Init(Sdl.SDL_INIT_JOYSTICK); game.window.viewport.LostFocus+= onLostFocus; game.window.viewport.GotFocus+= onGotFocus; bFocused= true; pUseFocus= true; mhelper= new MouseHelper(game.window.viewport); khelper= new KeyboardHelper(game.window.viewport); gamepadDetector= new FList<GamepadInfo>(); gamepadDetector.add(new GamepadInfo(15, 0, 3, typeof(Xbox360Gamepad))); gamepadDetector.add(new GamepadInfo(12, 1, 2, typeof(PS2Gamepad))); if(Sdl.SDL_NumJoysticks()> 0) { gamepad= getGamepadNoQuit(0); } }
// Draws the given list of models public void renderRange(FList<Model> models) { for(int i= 0; i< models.size; i++) models[i].render(ref currTextureID); }
public GUILabel() : base() { textSprites= new FList<GUISprite>(); }