Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public void Any4()
        {
            var list = FList.New(3);
            var any  = FList.Any(i => i > 3, list);

            Assert.IsFalse(any);
        }
Esempio n. 5
0
        public void Any1String()
        {
            var list = "123";
            var any  = FList.Any(i => i > '1', list);

            Assert.IsTrue(any);
        }
Esempio n. 6
0
        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));
            }
        }
Esempio n. 7
0
        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());
        }
Esempio n. 9
0
        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());
        }
Esempio n. 12
0
 protected GUIContainer()
     : base()
 {
     components=	new FList<GUIComponent>();
     focusedComp=	null;
     pSprite=	null;
 }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
 internal PluginManager(string relativePath)
 {
     pPlugins=	new FList<IPlugin>();;
     tags=	new string[]{"addon"};
     bInit=	new bool[8];
     defaultPath=	relativePath;
 }
Esempio n. 17
0
        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;
    }
Esempio n. 19
0
            public BaseClousotWorker(IWorkerId id, FList <string> baseArgs, IScheduler scheduler)
                : base(id, scheduler)
            {
                Contract.Requires(id != null);

                this.baseArgs = baseArgs;
            }
Esempio n. 20
0
 public void Head2()
 {
     var list = FList.New(5);
     var actual = FList.Head(list);
     var expected = 5;
     Assert.AreEqual(expected, actual);
 }
Esempio n. 21
0
        public void Any3()
        {
            var list = FList.New(3);
            var any  = FList.Any(i => i > 2, list);

            Assert.IsTrue(any);
        }
Esempio n. 22
0
 public void Head1String()
 {
     var list = "12345";
     var actual = FList.Head(list);
     var expected = '1';
     Assert.AreEqual(expected, actual);
 }
Esempio n. 23
0
        public void Any5()
        {
            var list = FList.Empty <int>();
            var any  = FList.Any(i => i > 3, list);

            Assert.IsFalse(any);
        }
Esempio n. 24
0
 public void Head1()
 {
     var list = FList.New(1, 2, 3, 4, 5);
     var actual = FList.Head(list);
     var expected = 1;
     Assert.AreEqual(expected, actual);
 }
Esempio n. 25
0
        public void Any2String()
        {
            var list = "123";
            var any  = FList.Any(i => i > '3', list);

            Assert.IsFalse(any);
        }
Esempio n. 26
0
        public void Elem1String()
        {
            var list     = "12345";
            var actual   = FList.Elem('3', list);
            var expected = true;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
        public void Elem5()
        {
            var list     = FList.New(5);
            var actual   = FList.Elem(6, list);
            var expected = false;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 30
0
        public void Elem3String()
        {
            var list     = "12345";
            var actual   = FList.Elem('6', list);
            var expected = false;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 31
0
        public void Elem4()
        {
            var list     = FList.New(5);
            var actual   = FList.Elem(5, list);
            var expected = true;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 32
0
        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);
        }
Esempio n. 33
0
        public void Elem6()
        {
            var list     = FList.Empty <int>();
            var actual   = FList.Elem(6, list);
            var expected = false;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 34
0
        protected GUIContainer()
            : base()
        {
            components=	new FList<GUIComponent>();
            focusedComp=	null;

            bEComponents=	false;

            e_components=	null;
        }
Esempio n. 35
0
        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;
        }
Esempio n. 36
0
      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;
      }
Esempio n. 37
0
 private void AddUpdate(Update upd) {
   Debug.Assert(!this.IsConstant, "modification of locked down egraph");
   this.updates = FList.Cons(upd, this.updates);
 }
Esempio n. 38
0
    /// <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;
    }
Esempio n. 39
0
 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;
 }
Esempio n. 42
0
 internal AudioPlayer(Game pmGame)
 {
     pMasterVolume=	1f;
     game=	pmGame;
     channels=	new FList<int>();
 }
Esempio n. 43
0
 // 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;
    }
Esempio n. 49
0
 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;
   }
 }
Esempio n. 50
0
        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)));
    }
Esempio n. 56
0
 public Spline()
 {
     points=	new FList<Point3f>();
     segmentSize=	0;
 }
Esempio n. 57
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);
            }
        }
Esempio n. 58
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);
 }
Esempio n. 59
0
 public GUILabel()
     : base()
 {
     textSprites=	new FList<GUISprite>();
 }