The Labs \ Source Viewer \ SSCLI \ Microsoft.JScript \ MemberInfoList

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. namespace Microsoft.JScript
  16. {
  17.    
  18.     using System;
  19.     using System.Reflection;
  20.    
  21.     public sealed class MemberInfoList
  22.     {
  23.         internal int count;
  24.         private MemberInfo[] list;
  25.        
  26.         internal MemberInfoList()
  27.         {
  28.             this.count = 0;
  29.             this.list = new MemberInfo[16];
  30.         }
  31.        
  32.         internal void Add(MemberInfo elem)
  33.         {
  34.             int n = this.count++;
  35.             if (this.list.Length == n)
  36.                 this.Grow();
  37.             this.list[n] = elem;
  38.         }
  39.        
  40.         internal void AddRange(MemberInfo[] elems)
  41.         {
  42.             foreach (MemberInfo mem in elems)
  43.                 this.Add(mem);
  44.         }
  45.        
  46.         private void Grow()
  47.         {
  48.             MemberInfo[] list = this.list;
  49.             int n = list.Length;
  50.             MemberInfo[] newList = this.list = new MemberInfo[n + 16];
  51.             for (int i = 0; i < n; i++)
  52.                 newList[i] = list[i];
  53.         }
  54.        
  55.         internal MemberInfo this[int i]
  56.         {
  57.             get { return this.list[i]; }
  58.             set { this.list[i] = value; }
  59.         }
  60.        
  61.         internal MemberInfo[] ToArray()
  62.         {
  63.             int n = this.count;
  64.             MemberInfo[] result = new MemberInfo[n];
  65.             MemberInfo[] list = this.list;
  66.             for (int i = 0; i < n; i++)
  67.                 result[i] = list[i];
  68.             return result;
  69.         }
  70.     }
  71.    
  72. }

Developer Fusion