public ComplexCustomizeHandler(IIntegratedCustomizeHandler singleHandler)
 {
     this.sortedArray_0 = new SortedArray <int, IIntegratedCustomizeHandler>();
     this.object_0      = new object();
     this.ilist_0       = new List <IIntegratedCustomizeHandler>();
     this.ilist_0       = new List <IIntegratedCustomizeHandler>();
     this.ilist_0.Add(singleHandler);
 }
Example #2
0
 public Class115(IProcess interface12_0)
 {
     this.sortedArray_0 = new SortedArray <int, IProcess>();
     this.object_0      = new object();
     this.ilist_0       = new List <IProcess>();
     this.ilist_0       = new List <IProcess>();
     this.ilist_0.Add(interface12_0);
 }
Example #3
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);
        }
Example #4
0
        public void RecursionTest(int expected, int searchNumber, params int[] numbers)
        {
            SortedArray <int>        sortedArray = new SortedArray <int>(numbers);
            BinaryChopStrategy <int> searcher    = new RecursionSearchStrategy();

            int result = sortedArray.Search(searchNumber, searcher);

            result.ShouldBe(expected);
        }
Example #5
0
        public List <string> GetGroupMembers(string groupID)
        {
            SortedArray <string> ary = this.SafeGetGroupMembers(groupID);

            if (ary == null)
            {
                return(null);
            }
            return(ary.GetAll());
        }
Example #6
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);
        }
Example #7
0
        public void Fire(string groupID, string memberID)
        {
            this.rapidPassiveEngine.CustomizeOutter.Send(this.groupInfoTypes.Fire, CompactPropertySerializer.Default.Serialize(new RecruitOrFireContract(groupID, memberID)));
            SortedArray <string> ary = this.groupCache.Get(groupID);

            if (ary != null)
            {
                ary.Remove(memberID);
            }
        }
Example #8
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);
        }
Example #9
0
        private void InitParams(Schedulare schedulare, ShiftsContainer shiftsContainer)
        {
            ShiftsContainer = shiftsContainer;

            OpenSet = new SortedArray <SchedulareState>(new SchedulareComparerArray());

            TreeRoot = new TreeNode <Schedulare>(schedulare);

            CloseSet = new SortedArray <SchedulareState>(new SchedulareComparerArray());
        }
Example #10
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);
        }
Example #11
0
        public void AppendRichText(string textContent, SortedArray <int, uint> imagePosition_imageID, Dictionary <int, Image> foreignObjectAry, Font font, Color color)
        {
            int count = this.Text.Length; //.TextLength

            if (imagePosition_imageID != null)
            {
                string pureText = textContent;
                //去掉表情和图片的占位符
                List <int> posList = imagePosition_imageID.GetAllKeyList();
                // List<int> foreignPosList = foreignObjectAry.Keys();

                List <int> tempList = new List <int>();
                tempList.AddRange(posList);
                foreach (int key in foreignObjectAry.Keys)
                {
                    tempList.Add(key);
                }

                tempList.Sort();

                for (int i = tempList.Count - 1; i >= 0; i--)
                {
                    pureText = pureText.Remove(tempList[i], 1);
                }
                this.AppendText(pureText);
                //插入表情
                for (int i = 0; i < tempList.Count; i++)
                {
                    int position = tempList[i];
                    if (posList.Contains(position))
                    {
                        this.InsertImage(imagePosition_imageID[position], count + position);
                    }
                    else
                    {
                        this.InsertImage(foreignObjectAry[position], count + position);
                    }
                }
            }
            else
            {
                this.AppendText(textContent);
            }

            this.Select(count, textContent.Length);
            if (color != null)
            {
                this.SelectionColor = color;
            }
            if (font != null)
            {
                this.SelectionFont = font;
            }
        }
Example #12
0
        public DirectorySnapshot FindRootDirectory(FullPathName rootPath)
        {
            var index = SortedArray.BinarySearch(_snapshot.ProjectRoots, rootPath, ProjectRootComparer);

            if (index >= 0)
            {
                return(_snapshot.ProjectRoots[index].Directory);
            }

            return(null);
        }
        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));
        }
        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));
        }
        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));
        }
Example #16
0
        /// <summary>
        /// 返回的集合不可修改。
        /// </summary>
        public List <string> GetGroupMembers(string groupID)
        {
            SortedArray <string> group = this.manager.Get(groupID);

            if (group == null)
            {
                return(null);
            }

            return(group.GetAllReadonly());
        }
 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();
 }
Example #18
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);
        }
Example #19
0
        internal void SomeoneQuitGroupNotify(string groupID, string memberID)
        {
            SortedArray <string> ary = this.groupCache.Get(groupID);

            if (ary != null)
            {
                ary.Remove(memberID);
            }
            if (this.SomeoneQuitGroup != null)
            {
                this.SomeoneQuitGroup(groupID, memberID);
            }
        }
Example #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());
        }
        public static Object Copy(this Object originalObject, bool OrginalTargetForDelegates = false)
        {
            ObjectExtensions.OrginalTargetForDelegates = OrginalTargetForDelegates;
            var Pos = InternalCopy(originalObject.GetType());

            visited = new SortedArray <ObjectContainer>(5);
            var Result = InternalCopys[Pos]
                             (originalObject);

            AtLast?.Invoke();
            AtLast = null;
            return(Result);
        }
Example #22
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]);
        }
    }
Example #23
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]);
        }
    }
Example #24
0
        public FileName CreateFileName(DirectoryName parent, string simpleName)
        {
            var directory = FindDirectory(parent);

            if (directory != null)
            {
                // Note: We found the corresponding parent, we just need to check the "simple" name part of the relative name.
                int index = SortedArray.BinarySearch(directory.Files, simpleName, FileComparer);
                if (index >= 0)
                {
                    return(directory.Files[index]);
                }
            }
            return(_previous.CreateFileName(parent, simpleName));
        }
        static void Main(string[] args)
        {
            int[] integer = new int[4] {
                4, 3, 2, 1
            };

            SortedArray sortedArray = new SortedArray();

            sortedArray.SetArray(integer);
            Console.WriteLine("Tableau d'origine :");
            sortedArray.GetArray();
            sortedArray.BubbleSort(integer);
            Console.WriteLine("Tableau trié :");
            sortedArray.GetArray();
        }
Example #26
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);
    }
Example #27
0
        public void Broadcast(string groupID, int broadcastType, byte[] broadcastContent, ActionTypeOnChannelIsBusy action, BroadcastChannelMode broadcastChannelMode)
        {
            if (broadcastChannelMode == BroadcastChannelMode.AllTransferByServer)
            {
                this.BroadcastByServer(groupID, broadcastType, broadcastContent, action);
                return;
            }

            if (broadcastChannelMode == BroadcastChannelMode.AllByP2PChannel)
            {
                this.BroadcastByP2PChannel(groupID, broadcastType, broadcastContent, action);
                return;
            }

            BroadcastContract contract = new BroadcastContract(this.currentUserID, groupID, broadcastType, broadcastContent, action);

            byte[] info = CompactPropertySerializer.Default.Serialize(contract);
            SortedArray <string> passiveGroupmates = this.SafeGetGroupMembers(groupID);

            if (passiveGroupmates == null)
            {
                return;
            }
            bool allP2P = true;

            foreach (string memberID in passiveGroupmates.GetAll())
            {
                if (memberID == this.currentUserID)
                {
                    continue;
                }

                if (this.rapidPassiveEngine.P2PController.IsP2PChannelExist(memberID))
                {
                    this.rapidPassiveEngine.CustomizeOutter.SendByP2PChannel(memberID, this.groupInfoTypes.Broadcast, info, ActionTypeOnNoP2PChannel.Discard, true, action);
                }
                else
                {
                    allP2P = false;
                }
            }

            if (!allP2P) //如果有一个在线用户没有P2P,则经过服务器中转。
            {
                this.rapidPassiveEngine.CustomizeOutter.Send(null, this.groupInfoTypes.Broadcast, info, true, action);
            }
        }
Example #28
0
        /// <summary>
        /// Constructed with the NFA size (amount of states), the initial state and the
        /// final state
        /// </summary>
        /// <param name="size_">Amount of states.</param>
        /// <param name="initial_">Initial state.</param>
        /// <param name="final_">Final state.</param>
        private LenvstnNFA(int size_, state initial_, Set <state> final_)
        {
            initial = initial_;
            final   = final_;
            size    = size_;

            inputs = new SortedArray <input>();

            // Initializes transTable with an "empty graph", no transitions between its
            // states
            transTable = new input[size][];

            for (int i = 0; i < size; ++i)
            {
                transTable[i] = new input[size];
            }
        }
Example #29
0
 public bool AnyUse()
 {
     if (RunIfNotRuning_Name == null)
     {
         RunIfNotRuning_Name = new SortedArray <string>();
     }
     if (RunIfNotRuning_Name.Length == 0 &&
         RunIfAnyNotRuning_flag == false)
     {
         RunIfAnyNotRuning_flag = true;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #30
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);
 }
Example #31
0
        public void AppendRichText(string textContent, SortedArray <int, uint> imagePosition_imageID, Dictionary <int, Image> foreignObjectAry, Font font, Color color)
        {
            int length = this.Text.Length;

            if (imagePosition_imageID != null)
            {
                int        num3;
                string     text       = textContent;
                List <int> allKeyList = imagePosition_imageID.GetAllKeyList();
                List <int> list2      = new List <int>();
                list2.AddRange(allKeyList);
                foreach (int num2 in foreignObjectAry.Keys)
                {
                    list2.Add(num2);
                }
                list2.Sort();
                for (num3 = list2.Count - 1; num3 >= 0; num3--)
                {
                    text = text.Remove(list2[num3], 1);
                }
                base.AppendText(text);
                for (num3 = 0; num3 < list2.Count; num3++)
                {
                    int item = list2[num3];
                    if (allKeyList.Contains(item))
                    {
                        this.InsertImage(imagePosition_imageID[item], length + item);
                    }
                    else
                    {
                        this.InsertImage(foreignObjectAry[item], length + item);
                    }
                }
            }
            else
            {
                base.AppendText(textContent);
            }
            base.Select(length, textContent.Length);
            base.SelectionColor = color;
            if (font != null)
            {
                base.SelectionFont = font;
            }
        }
Example #32
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);
            }
        }
Example #33
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);
            }
        }
Example #34
0
 public void deliver(SCTPStream s, SortedArray <DataChunk> a, SCTPStreamListener l)
 {
     Logger.Debug("in deliver() for stream " + s.getLabel() + " with " + a.Count + " chunks. ");
     // strictly this should be looking at flags etc, and bundling the result into a message
     foreach (DataChunk dc in a)
     {
         if (dc.getDCEP() != null)
         {
             Logger.Debug("in deliver() for a DCEP message " + dc.getDataAsString());
         }
         else
         {
             Logger.Debug("inbound data chunk is " + dc.ToString());
             l.onMessage(s, dc.getDataAsString());
         }
     }
     a.Clear();
 }
Example #35
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);
        }
Example #36
0
        public void QuitGroup(string groupID, string userID)
        {
            lock (this.locker)
            {
                SortedArray <string> group = this.manager.Get(groupID);
                if (group == null)
                {
                    return;
                }

                group.Remove(userID);
            }

            if (this.SomeoneQuitGroup != null)
            {
                this.SomeoneQuitGroup(groupID, userID);
            }
        }
        /// <summary>
        /// AppendRichText 在现有内容后面追加富文本。
        /// </summary>
        /// <param name="textContent">文本内容</param>
        /// <param name="imagePosition_imageID">图片在textContent中的位置以及图片的ID</param>
        public void AppendRichText(string textContent, SortedArray<int, uint> imagePosition_imageID ,Font font ,Color color)
        {
            int count = this.Text.Length; //.TextLength
            if (imagePosition_imageID != null)
            {               
                string temp = textContent;
                List<int> posList = imagePosition_imageID.GetAllKeyList();
                for (int i = posList.Count - 1; i >= 0; i--)
                {
                    temp = temp.Remove(posList[i], 1);
                }
                this.AppendText(temp);

                for (int i = 0; i < posList.Count; i++)
                {
                    int position = posList[i];
                    this.InsertImage(imagePosition_imageID[position], count + position);
                }
            }
            else
            {                
                this.AppendText(textContent);
            }

            this.Select(count, textContent.Length);
            if (color != null)
            {
                this.SelectionColor = color;
            }
            if (font != null)
            {
                this.SelectionFont = font;
            }
        }
        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));
        }
        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));
        }
 /// <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;
 }
        public void FindPostionForElementTest()
        {
            var data = new[] { "aba", "maria", "ana", "ioana", null, null, null, null };
            var element = "ana";

            var array = new SortedArray<string>(data, 4);
            array.SortArray();
            var expectedResult=array.Find(element);

            Assert.AreEqual(1, expectedResult);
        }
        public void AppendRichText(string textContent, SortedArray<int, uint> imagePosition_imageID, Dictionary<int, Image> foreignObjectAry, Font font, Color color)
        {
            int count = this.Text.Length; //.TextLength
            if (imagePosition_imageID != null)
            {
                string pureText = textContent;
                //去掉表情和图片的占位符
                List<int> posList = imagePosition_imageID.GetAllKeyList();
               // List<int> foreignPosList = foreignObjectAry.Keys();

                List<int> tempList = new List<int>();
                tempList.AddRange(posList);
                foreach (int key in foreignObjectAry.Keys)
                {
                    tempList.Add(key);
                }
               
                tempList.Sort();

                for (int i = tempList.Count - 1; i >= 0; i--)
                {
                    pureText = pureText.Remove(tempList[i], 1);
                }
                this.AppendText(pureText);
                //插入表情
                for (int i = 0; i < tempList.Count; i++)
                {
                    int position = tempList[i];
                    if (posList.Contains(position))
                    {
                        this.InsertImage(imagePosition_imageID[position], count + position);
                    }
                    else
                    {
                        this.InsertImage(foreignObjectAry[position], count + position);
                    }
                }
            }
            else
            {
                this.AppendText(textContent);
            }

            this.Select(count, textContent.Length);
            if (color != null)
            {
                this.SelectionColor = color;
            }
            if (font != null)
            {
                this.SelectionFont = font;
            }
        } 
        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());
            }
        }