/// <summary>
        /// Gets or sets <see cref="NetworkParametersMatrix"/> corresponding to the specified frequency.
        /// </summary>
        /// <param name="frequency">The specified frequency associated with the network data.</param>
        /// <returns>The <see cref="NetworkParametersMatrix"/> measured or derived at <paramref name="frequency"/>.</returns>
        public TMatrix this[double frequency]
        {
            get
            {
                bool exists = networkParameters.TryGetValue(frequency, out TMatrix value);
                if (exists)
                {
                    return(value);
                }

                /*else if (Interpolation.Enabled)
                 * {
                 *
                 * }*/
                else
                {
                    throw new KeyNotFoundException($"No value exists for frequency {frequency}.");
                }
            }
            set
            {
                if (value.NumPorts != NumberOfPorts)
                {
                    throw new ArgumentException("All network parameter matrices must have the same number of ports.");
                }
                networkParameters[frequency] = value;
                frequencies.Add(frequency);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a transition between two states.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="in"></param>
        public void AddTrans(state from, state to, input @in)
        {
            IsLegalState(from);
            IsLegalState(to);

            transTable[from][to] = @in;

            if (@in != (char)Constants.Epsilon)
            {
                inputs.Add(@in);
            }
        }
Ejemplo n.º 3
0
    public static void Main()
    {
        SortedArray <int> coll = new SortedArray <int>(8);

        coll.Add(3);
        coll.Add(1);
        coll.Add(5);
        coll.Add(-1);

        for (int i = 0; i < coll.Count; ++i)
        {
            Console.WriteLine(coll[i]);
        }
    }
Ejemplo n.º 4
0
    public static void Main()
    {
        SortedArray <string> coll = new SortedArray <string>(8);

        coll.Add("LEIC");
        coll.Add("ISEL");
        coll.Add("LI41N");
        coll.Add("AVE");

        for (int i = 0; i < coll.Count; ++i)
        {
            Console.WriteLine("{0}: \"{1}\"", i, coll[i]);
        }
    }
Ejemplo n.º 5
0
    public static void Main(String[] args) {
      //       SortedArray<Object> sarr = new SortedArray<Object>();
      SCG.IComparer<Rec<string,int>> lexico =
	new DelegateComparer<Rec<string,int>>(
	    delegate(Rec<string,int> r1, Rec<string,int> r2) { 
	      int order = r1.X1.CompareTo(r2.X1);
	      return order==0 ? r1.X2.CompareTo(r2.X2) : order;
	    });
      SortedArray<Rec<string,int>> sarr = new SortedArray<Rec<string,int>>(lexico);
      sarr.Add(new Rec<string,int>("ole", 32));
      sarr.Add(new Rec<string,int>("hans", 77));
      sarr.Add(new Rec<string,int>("ole", 63));
      foreach (Rec<string,int> r in sarr)
	Console.WriteLine(r);
    }
Ejemplo n.º 6
0
        public void testDeliverSingle()
        {
            Console.WriteLine("--> deliver single");
            SCTPStream s = mockStream();
            SortedArray <DataChunk> stash = new SortedArray <DataChunk>();
            DataChunk single     = new DataChunk();
            string    teststring = "Test string";

            single.setData(teststring.getBytes());
            single.setPpid(DataChunk.WEBRTCstring);
            single.setFlags(DataChunk.SINGLEFLAG);
            single.setTsn(_tsn++);
            single.setsSeqNo(0);
            stash.Add(single);
            List <string> result = new List <string>();

            result.Add(teststring);
            SCTPStreamListener     l        = new CheckingStreamListener(result);
            OrderedStreamBehaviour instance = new OrderedStreamBehaviour();

            instance.deliver(s, stash, l);
            int remain = result.Count;

            Assert.AreEqual(remain, 0);
        }
Ejemplo n.º 7
0
        public void testDeliverTwo()
        {
            Console.WriteLine("--> deliver two");
            SCTPStream s = mockStream();
            SortedArray <DataChunk> stash = new SortedArray <DataChunk>();

            string[]      teststrings = new string[] { "Test string A", "Test string B" };
            List <string> result      = new List <string>();
            int           n           = 0;

            foreach (string ts in teststrings)
            {
                DataChunk single = new DataChunk();
                single.setTsn(_tsn++);
                single.setsSeqNo(n++);
                single.setData(ts.getBytes());
                single.setPpid(DataChunk.WEBRTCstring);
                single.setFlags(DataChunk.SINGLEFLAG);
                stash.Add(single);
                result.Add(ts);
            }
            SCTPStreamListener     l        = new CheckingStreamListener(result);
            OrderedStreamBehaviour instance = new OrderedStreamBehaviour();

            instance.deliver(s, stash, l);

            int remain = result.Count;

            Assert.AreEqual(remain, 0);
        }
Ejemplo n.º 8
0
        public void testFillLongstring()
        {
            Console.WriteLine("--> fill long");
            StringBuilder sb = new StringBuilder("This is a");

            for (int i = 0; i < 1030; i++)
            {
                sb.Append(" long");
            }
            sb.Append(" test.");
            string                  teststring = sb.ToString();
            SCTPMessage             instance   = new SCTPMessage(teststring, _fakeStream);
            SortedArray <DataChunk> chunks     = new SortedArray <DataChunk>();
            long tsn = 111;

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                dc.setTsn((uint)tsn++);
                instance.fill(dc);
                chunks.Add(dc);
            }
            double pktsz    = chunks.First.getDataSize();
            int    estimate = (int)Math.Ceiling(teststring.Length / pktsz);

            Assert.AreEqual(chunks.Count, estimate);
        }
Ejemplo n.º 9
0
        public void testDeliverVeryManyMessages()
        {
            Console.WriteLine("--> deliver very many messages");

            string[] teststrings = new string[10000];
            for (int i = 0; i < teststrings.Length; i++)
            {
                teststrings[i] = "Test string " + i;
            }
            SCTPStream s = mockStream();
            SortedArray <DataChunk> stash  = new SortedArray <DataChunk>();
            List <string>           result = new List <string>();
            ushort mo = (ushort)0;

            foreach (string ts in teststrings)
            {
                DataChunk single = new DataChunk();
                single.setTsn(_tsn++);
                single.setsSeqNo((int)mo++);
                single.setData(ts.getBytes());
                single.setPpid(DataChunk.WEBRTCstring);
                single.setFlags(DataChunk.SINGLEFLAG);
                stash.Add(single);
                result.Add(ts);
            }
            SCTPStreamListener     l        = new CheckingStreamListener(result);
            OrderedStreamBehaviour instance = new OrderedStreamBehaviour();

            instance.deliver(s, stash, l);
        }
Ejemplo n.º 10
0
 public static void Main(String[] args)
 {
     // SortedArray<Object> sarr = new SortedArray<Object>();
     var lexico = C5.Comparers.ComparerFactory<Rec<string, int>>.CreateComparer(
         (r1, r2) =>
             {
                 int order = r1.X1.CompareTo(r2.X1);
                 return order == 0 ? r1.X2.CompareTo(r2.X2) : order;
             }
         );
     SortedArray<Rec<string, int>> sarr = new SortedArray<Rec<string, int>>(lexico);
     sarr.Add(new Rec<string, int>("ole", 32));
     sarr.Add(new Rec<string, int>("hans", 77));
     sarr.Add(new Rec<string, int>("ole", 63));
     foreach (Rec<string, int> r in sarr)
         Console.WriteLine(r);
 }
Ejemplo n.º 11
0
        public static TreeDictionary <int, int> ProcessRanges(IEnumerable <Tuple <int, int> > ranges)
        {
            var summedRangeEdges = new TreeDictionary <int, int>();

            foreach (var currentRange in ranges)
            {
                var currentRangeLeft  = currentRange.Item1;
                var currentRangeRight = currentRange.Item2;

                // Add left boundary if it isn't already there, with its value set as the value of the summed range it is included in, otherwise zero
                // E.g.: 1 to 10 with value 1 becomes 1 to 5 with value 1, 5 to 10 with value 1

                // Check if the node exists in the Tree
                if (!summedRangeEdges.Exists(x => x.Key == currentRangeLeft))
                {
                    summedRangeEdges.Add(currentRangeLeft,
                                         summedRangeEdges.TryPredecessor(currentRangeLeft, out var predecessor)
                            ? predecessor.Value
                            : 0);
                }

                // Increment the value of all summed range edges between the left boundary (inclusive) and the right boundary (exclusive)
                var summedRangesSubMap = summedRangeEdges.RangeFromTo(currentRangeLeft, currentRangeRight);

                var keys = new SortedArray <int>();
                foreach (var key in summedRangesSubMap)
                {
                    keys.Add(key.Key);
                }

                foreach (var key in keys)
                {
                    summedRangeEdges[key]++;
                }

                // Add the right boundary
                // If there isn't a summed range edge to its left, use 0 for the value (should never happen as per the "put" above)
                // If the right boundary was already in the map, leave it as is
                // If the right boundary wasn't in the map, use the value to its left minus 1 (since this is a right boundary, which means a range was closed)

                if (summedRangeEdges.Exists(x => x.Key == currentRangeRight))
                {
                    continue;
                }
                {
                    if (summedRangeEdges.TryPredecessor(currentRangeRight, out var predecessor))
                    {
                        summedRangeEdges.Add(currentRangeRight, predecessor.Value - 1);
                    }
                    else
                    {
                        summedRangeEdges.Add(currentRangeRight, 0);
                    }
                }
            }

            return(summedRangeEdges);
        }
Ejemplo n.º 12
0
        /// <inheritdoc />
        public Camera()
        {
            Constants = new ConstantBuffer <CameraData>();

            _fovY             = 85;
            ClipNear          = 0.3f;
            ClipFar           = 2000f;
            _projectionMatrix = Matrix.Identity;
            _cframe           = CFrame.Identity;
            _focus            = CFrame.Identity;

            _attachBehaviour     = new AttachBehaviour(this);
            _classicBehaviour    = new ClassicBehaviour(this);
            _fixedBehaviour      = new FixedBehaviour(this);
            _followBehaviour     = new FollowBehaviour(this);
            _scriptableBehaviour = new ScriptableBehaviour(this);
            _trackBehaviour      = new TrackBehaviour(this);
            _watchBehaviour      = new WatchBehaviour(this);

            CameraType = CameraType.Fixed;

            LayerCollectors     = new SortedArray <LayerCollector>(new LayerCollector.PriorityComparer());
            Gui3Ds              = new ArrayList <GuiBase3D>();
            ViewportSizeChanged = new Signal <Vector2>(this);
            Moved = new Signal(this);

            _roProvider = new WorldRenderer();

            FrustumCulling = true;

            PostEffects = new SortedArray <PostEffect>(new PostEffect.PostEffectSorter());

            _bloomEffect = new BloomEffect();
            _bloomEffect.SetCamera(this);
            _ambientOcclusion = new AmbientOcclusionEffect();
            _ambientOcclusion.SetCamera(this);
            _colourCorrection = new ColourCorrectionEffect();
            _colourCorrection.SetCamera(this);
            PostEffects.Add(_bloomEffect);
            PostEffects.Add(_ambientOcclusion);
            PostEffects.Add(_colourCorrection);

            NeedsResize = true;
        }
Ejemplo n.º 13
0
        public SortedArray <DataChunk> ToArray()
        {
            var list = new SortedArray <DataChunk>();

            for (uint i = start.getTsn(); i <= end?.getTsn(); i++)
            {
                list.Add(Chunks[i]);
            }
            return(list);
        }
Ejemplo n.º 14
0
        public static void Main(String[] args)
        {
            //       SortedArray<Object> sarr = new SortedArray<Object>();
            SCG.IComparer <Rec <string, int> > lexico =
                new DelegateComparer <Rec <string, int> >(
                    delegate(Rec <string, int> r1, Rec <string, int> r2) {
                int order = r1.X1.CompareTo(r2.X1);
                return(order == 0 ? r1.X2.CompareTo(r2.X2) : order);
            });
            SortedArray <Rec <string, int> > sarr = new SortedArray <Rec <string, int> >(lexico);

            sarr.Add(new Rec <string, int>("ole", 32));
            sarr.Add(new Rec <string, int>("hans", 77));
            sarr.Add(new Rec <string, int>("ole", 63));
            foreach (Rec <string, int> r in sarr)
            {
                Console.WriteLine(r);
            }
        }
Ejemplo n.º 15
0
        public SortedArray <T> CopyToSortedArray <T>(ICollection <T> lst)
        {
            SortedArray <T> lstCopy = new SortedArray <T>();

            foreach (var item in lst)
            {
                lstCopy.Add((T)item);
            }
            return(lstCopy);
        }
Ejemplo n.º 16
0
        void oneMissingPartMessages(string[] teststrings, string es, int ec)
        {
            SCTPStream s = mockStream();
            SortedArray <DataChunk> stash  = new SortedArray <DataChunk>();
            List <string>           result = new List <string>();
            int  n = 0;
            int  expectedToRemain = 0;
            bool skip             = false;

            foreach (string ts in teststrings)
            {
                for (int i = 0; i < ts.Length; i++)
                {
                    DataChunk single = new DataChunk();
                    single.setTsn(_tsn++);
                    single.setsSeqNo(n);
                    string letter = ts.Substring(i, 1);
                    single.setData(letter.getBytes());
                    single.setPpid(DataChunk.WEBRTCstring);
                    if (i == 0)
                    {
                        single.setFlags(DataChunk.BEGINFLAG);
                    }
                    else if (i == ts.Length - 1)
                    {
                        single.setFlags(DataChunk.ENDFLAG);
                    }
                    if ((ec != i) || !ts.Equals(es))
                    {
                        stash.Add(single);
                    }
                }
                if (ts.Equals(es))
                {
                    skip = true;
                }
                if (skip)
                {
                    expectedToRemain++;
                }
                result.Add(ts);
                n++;
            }

            SCTPStreamListener     l        = new CheckingStreamListener(result);
            OrderedStreamBehaviour instance = new OrderedStreamBehaviour();

            instance.deliver(s, stash, l);

            int remain = result.Count;

            //Console.WriteLine("expected:" + expectedToRemain + " remain:" + remain);

            Assert.AreEqual(remain, expectedToRemain);
        }
Ejemplo n.º 17
0
        public void AddFirstElementInAnEmptyArrayTest()
        {
            var data = new string[8] ;
            var newElement = "d";

            var sortedArray = new SortedArray<string>(data, 0);
            sortedArray.Add(newElement);

            Assert.AreEqual(1, sortedArray.GetCount());
            Assert.AreEqual(newElement, sortedArray.GetData(0));
        }
Ejemplo n.º 18
0
        public void AddFirstElementInSortedArrayTest()
        {
            var data = new[] { "b", "c", null, null, null, null, null, null, null };
            var newElement = "a";

            var sortedArray = new SortedArray<string>(data, 2);
            sortedArray.Add(newElement);

            Assert.AreEqual(3, sortedArray.GetCount());
            Assert.AreEqual(newElement, sortedArray.GetData(0));
        }
Ejemplo n.º 19
0
        public static void Main(String[] args)
        {
            // SortedArray<Object> sarr = new SortedArray<Object>();
            var lexico = C5.Comparers.ComparerFactory <Rec <string, int> > .CreateComparer(
                (r1, r2) =>
            {
                int order = r1.X1.CompareTo(r2.X1);
                return(order == 0 ? r1.X2.CompareTo(r2.X2) : order);
            }
                );

            SortedArray <Rec <string, int> > sarr = new SortedArray <Rec <string, int> >(lexico);

            sarr.Add(new Rec <string, int>("ole", 32));
            sarr.Add(new Rec <string, int>("hans", 77));
            sarr.Add(new Rec <string, int>("ole", 63));
            foreach (Rec <string, int> r in sarr)
            {
                Console.WriteLine(r);
            }
        }
Ejemplo n.º 20
0
 public List<string> GetGroupmates(string userID)
 {
     SortedArray<string> array = new SortedArray<string>();
     foreach (SortedArray<string> group in this.manager.GetAll())
     {
         if (group.Contains(userID))
         {
             array.Add(group.GetAll());
         }
     }
     return array.GetAll();
 }
Ejemplo n.º 21
0
        public void deliverUnorderedPackets(int seed)
        {
            Random rand = new Random(seed);             // deliberately not crypto random so test is repeatable

            // Console.WriteLine("seed = "+seed);
            string[]         teststrings = { "Test string A, ", "Test string B ", "and Test string C" };
            SCTPStream       s           = mockStream();
            List <string>    result      = new List <string>();
            int              n           = 0;
            List <DataChunk> all         = new List <DataChunk>();

            foreach (string ts in teststrings)
            {
                for (int i = 0; i < ts.Length; i++)
                {
                    DataChunk single = new DataChunk();
                    single.setTsn(_tsn++);
                    single.setsSeqNo(n);
                    string letter = ts.Substring(i, 1);
                    single.setData(letter.getBytes());
                    single.setPpid(DataChunk.WEBRTCstring);
                    if (i == 0)
                    {
                        single.setFlags(DataChunk.BEGINFLAG);
                    }
                    else if (i == ts.Length - 1)
                    {
                        single.setFlags(DataChunk.ENDFLAG);
                    }
                    all.Add(single);
                }
                result.Add(ts);
                n++;
            }

            SCTPStreamListener      l        = new CheckingStreamListener(result);
            OrderedStreamBehaviour  instance = new OrderedStreamBehaviour();
            SortedArray <DataChunk> stash    = new SortedArray <DataChunk>();

            while (all.Count > 0)
            {
                int       v = rand.Next(all.Count);
                DataChunk c = all[v];
                all.RemoveAt(v);
                stash.Add(c);
                instance.deliver(s, stash, l);
            }

            int remain = result.Count;

            Assert.AreEqual(remain, 0);
        }
Ejemplo n.º 22
0
        public List <string> GetGroupmates(string userID)
        {
            SortedArray <string> array = new SortedArray <string>();

            foreach (SortedArray <string> group in this.manager.GetAll())
            {
                if (group.Contains(userID))
                {
                    array.Add(group.GetAll());
                }
            }
            return(array.GetAll());
        }
        /// <summary>
        /// Creates a new <see cref="NetworkParametersCollection{TMatrix}"/> from an existing <see cref="SCG.IList{T}"/> of
        /// <see cref="FrequencyParametersPair{TMatrix}"/> pairs.
        /// </summary>
        /// <param name="parameters">The list of parameters </param>
        /// <param name="sorted"></param>
        public NetworkParametersCollection(SCG.IList <FrequencyParametersPair <TMatrix> > parameters, bool sorted = false)
        {
            networkParameters = new Dictionary <double, TMatrix>(parameters.Count);
            frequencies       = new SortedArray <double>(parameters.Count);

            foreach (var(frequency, data) in parameters)
            {
                networkParameters[frequency] = data;
                if (!sorted)
                {
                    frequencies.Add(frequency);
                }
            }
            if (sorted)
            {
                frequencies.AddSorted(parameters.Select(p => p.Frequency_Hz));
            }
        }
Ejemplo n.º 24
0
        internal void SomeoneJoinGroupNotify(string groupID, string memberID)
        {
            SortedArray <string> ary = this.groupCache.Get(groupID);

            if (ary != null)
            {
                ary.Add(memberID);
                if (this.tryP2PWhenGroupmateConnected)
                {
                    this.rapidPassiveEngine.P2PController.P2PConnectAsyn(memberID);
                }
            }

            if (this.SomeoneJoinGroup != null)
            {
                this.SomeoneJoinGroup(groupID, memberID);
            }
        }
Ejemplo n.º 25
0
        public void JoinGroup(string groupID, string userID)
        {
            lock (this.locker)
            {
                SortedArray <string> group = this.manager.Get(groupID);
                if (group == null)
                {
                    this.manager.Add(groupID, new SortedArray <string>());
                    group = this.manager.Get(groupID);
                }
                group.Add(userID);
            }

            if (this.SomeoneJoinGroup != null)
            {
                this.SomeoneJoinGroup(groupID, userID);
            }
        }
Ejemplo n.º 26
0
        public void testFillShortstring()
        {
            Console.WriteLine("--> fill short string ");
            string                  teststring = "This is a short test";
            SCTPMessage             instance   = new SCTPMessage(teststring, _fakeStream);
            SortedArray <DataChunk> chunks     = new SortedArray <DataChunk>();

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                instance.fill(dc);
                chunks.Add(dc);
            }
            Assert.AreEqual(chunks.Count, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCstring);
        }
Ejemplo n.º 27
0
        /*Indirectamente lo usa ComprobanteDePago*/
        public static ArrayList GetListArray(string IdResponsable, string IdCaja)
        {
            SortedArray lista      = new SortedArray();
            DataSet     instancias = null;

            if (IdResponsable != null && IdResponsable != string.Empty && Variables.GetValueBool("Cajas.Seguridad.PermiteMovimientosPorTodosLosResponsables") == true)
            {
                instancias = mz.erp.dataaccess.tfi_InstanciasCaja.GetListCajasDeTodosLosResponsables(IdResponsable, IdCaja);
            }
            else
            {
                instancias = mz.erp.dataaccess.tfi_InstanciasCaja.GetList(IdResponsable, IdCaja);
            }
            foreach (DataRow row in instancias.Tables[0].Rows)
            {
                lista.Add((string)row["IdInstanciaCaja"]);
            }
            return((ArrayList)lista);
        }
Ejemplo n.º 28
0
        public SortedArray <int, uint> GetAllImage(out bool containsForeignObject)
        {
            containsForeignObject = false;
            SortedArray <int, uint> array       = new SortedArray <int, uint>();
            List <REOBJECT>         allREOBJECT = this.RichEditOle.GetAllREOBJECT();

            for (int i = 0; i < allREOBJECT.Count; i++)
            {
                if (allREOBJECT[i].dwUser != 0)
                {
                    array.Add(allREOBJECT[i].posistion, allREOBJECT[i].dwUser);
                }
                else
                {
                    containsForeignObject = true;
                }
            }
            return(array);
        }
Ejemplo n.º 29
0
        public void testFillShortBlob()
        {
            Console.WriteLine("--> fill short blob ");
            byte[] testBlob = new byte[21];
            _rand.NextBytes(testBlob);
            SCTPMessage             instance = new SCTPMessage(testBlob, _fakeStream);
            SortedArray <DataChunk> chunks   = new SortedArray <DataChunk>();

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                instance.fill(dc);
                chunks.Add(dc);
            }
            Assert.AreEqual(chunks.Count, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCBINARY);
        }
Ejemplo n.º 30
0
        public bool Recruit(string groupID, string memberID)
        {
            byte[] response = this.rapidPassiveEngine.CustomizeOutter.Query(this.groupInfoTypes.Recruit, CompactPropertySerializer.Default.Serialize(new RecruitOrFireContract(groupID, memberID)));
            bool   suc      = BitConverter.ToBoolean(response, 0);

            if (suc)
            {
                SortedArray <string> ary = this.groupCache.Get(groupID);
                if (ary != null)
                {
                    ary.Add(memberID);
                }

                if (this.tryP2PWhenGroupmateConnected)
                {
                    this.rapidPassiveEngine.P2PController.P2PConnectAsyn(memberID);
                }
            }
            return(suc);
        }
Ejemplo n.º 31
0
        public void Offline(string userID)
        {
            SortedArray <string> array = new SortedArray <string>();

            lock (this.locker)
            {
                foreach (SortedArray <string> group in this.manager.GetAll())
                {
                    if (group.Contains(userID))
                    {
                        array.Add(group.GetAll());
                        group.Remove(userID);
                    }
                }
            }

            if (this.GroupmateOffline != null)
            {
                this.GroupmateOffline(userID, array.GetAll());
            }
        }
Ejemplo n.º 32
0
        public void testEmptyBlob()
        {
            Console.WriteLine("--> fill empty blob");
            byte[]                  testBlob = new byte[0];
            SCTPMessage             instance = new SCTPMessage(testBlob, _fakeStream);
            SortedArray <DataChunk> chunks   = new SortedArray <DataChunk>();
            long tsn = 111;

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                dc.setTsn((uint)tsn++);
                instance.fill(dc);
                chunks.Add(dc);
            }
            Assert.AreEqual(chunks.Count, 1);
            int pktsz = chunks.First.getDataSize();

            Assert.AreEqual(pktsz, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCBINARYEMPTY);
        }
Ejemplo n.º 33
0
        void multiPartMessage(string[] teststrings)
        {
            SCTPStream s = mockStream();
            SortedArray <DataChunk> stash  = new SortedArray <DataChunk>();
            List <string>           result = new List <string>();
            int           n  = 0;
            StringBuilder bs = new StringBuilder();

            foreach (string ts in teststrings)
            {
                DataChunk single = new DataChunk();
                single.setTsn((uint)_tsn++);
                single.setsSeqNo(0);
                single.setData(ts.getBytes());
                single.setPpid(DataChunk.WEBRTCstring);
                if (n == 0)
                {
                    single.setFlags(DataChunk.BEGINFLAG);
                }
                else if (n == teststrings.Length - 1)
                {
                    single.setFlags(DataChunk.ENDFLAG);
                }
                n++;
                bs.Append(ts);
                stash.Add(single);
            }
            result.Add(bs.ToString());
            SCTPStreamListener       l        = new CheckingStreamListener(result);
            UnorderedStreamBehaviour instance = new UnorderedStreamBehaviour();

            instance.deliver(s, stash, l);

            int remain = result.Count;

            Assert.AreEqual(remain, 0);
        }
Ejemplo n.º 34
0
        public void testEmptystring()
        {
            Console.WriteLine("--> fill empty string");
            StringBuilder           sb         = new StringBuilder("");
            string                  teststring = sb.ToString();
            SCTPMessage             instance   = new SCTPMessage(teststring, _fakeStream);
            SortedArray <DataChunk> chunks     = new SortedArray <DataChunk>();
            long tsn = 111;

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                dc.setTsn((uint)tsn++);
                instance.fill(dc);
                chunks.Add(dc);
            }
            int pktsz = chunks.First.getDataSize();

            Assert.AreEqual(chunks.Count, 1);
            Assert.AreEqual(pktsz, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCstringEMPTY);
        }
Ejemplo n.º 35
0
        void dontDeliverOnePart(int flag)
        {
            SCTPStream s = mockStream();
            SortedArray <DataChunk> stash = new SortedArray <DataChunk>();
            DataChunk single     = new DataChunk();
            string    teststring = "Test string";

            single.setData(teststring.getBytes());
            single.setPpid(DataChunk.WEBRTCstring);
            single.setFlags(flag);
            single.setTsn(_tsn++);
            single.setsSeqNo(0);
            stash.Add(single);
            List <string> result = new List <string>();

            result.Add(teststring);
            SCTPStreamListener     l        = new CheckingStreamListener(result);
            OrderedStreamBehaviour instance = new OrderedStreamBehaviour();

            instance.deliver(s, stash, l);
            int remain = result.Count;

            Assert.AreEqual(1, remain);
        }
Ejemplo n.º 36
0
        public void SortArrayTest()
        {
            var data = new[] {"maria", "ana", "ioana", null, null, null, null, null};
            var newElement = "bianca";

            var array=new SortedArray<string>(data,3);
            array.Add(newElement);
            array.SortArray();

            Assert.AreEqual(newElement,array.GetData(1));
        }
Ejemplo n.º 37
0
 /// <summary>
 /// GetAllImage 获取Box中每一张由IImagePathGetter管理的图片的位置和标志
 /// </summary>        
 /// <param name="containsForeignObject">内容中是否包含不是由IImagePathGetter管理的图片对象</param>
 /// <returns>key为位置,val为图片的ID</returns>
 public SortedArray<int, uint> GetAllImage(out bool containsForeignObject)
 {
     containsForeignObject = false;
     
     SortedArray<int, uint> array = new SortedArray<int, uint>();
     List<REOBJECT> list = this.RichEditOle.GetAllREOBJECT();
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].dwUser != 0)
         {
             array.Add(list[i].posistion, list[i].dwUser);
         }
         else
         {  
             containsForeignObject = true;
         }
     }
    
     return array;
 }
Ejemplo n.º 38
0
        public void Offline(string userID)
        {
            SortedArray<string> array = new SortedArray<string>();
            lock (this.locker)
            {
                foreach (SortedArray<string> group in this.manager.GetAll())
                {
                    if (group.Contains(userID))
                    {
                        array.Add(group.GetAll());
                        group.Remove(userID);
                    }
                }
            }

            if (this.GroupmateOffline != null)
            {
                this.GroupmateOffline(userID, array.GetAll());
            }
        }
Ejemplo n.º 39
0
        public void AddLastElementInSortedArrayTest()
        {
            var data = new[] { "b", "c", "e", null, null, null, null, null, null };
            var newElement = "f";

            var sortedArray = new SortedArray<string>(data, 3);
            sortedArray.Add(newElement);

            Assert.AreEqual(4, sortedArray.GetCount());
            Assert.AreEqual(newElement, sortedArray.GetData(3));
        }
Ejemplo n.º 40
0
        public void SortArrayWhenFirstElementIsSmallerTest()
        {
            var data = new[] {"aba", "maria", "ana", "ioana",null, null, null, null };
            var newElement = "bianca";

            var array = new SortedArray<string>(data, 4);
            array.Add(newElement);
            //array.SortArray();

            Assert.AreEqual(newElement, array.GetData(2));
        }