~ubuntu-branches/ubuntu/lucid/mono/lucid

« back to all changes in this revision

Viewing changes to mcs/class/corlib/System.Collections.Generic/Dictionary.cs

  • Committer: Bazaar Package Importer
  • Author(s): Mirco Bauer
  • Date: 2009-07-30 19:35:10 UTC
  • mto: (5.2.2 squeeze)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090730193510-cdttfvqokq2kmdvh
Tags: upstream-2.4.2.3+dfsg
ImportĀ upstreamĀ versionĀ 2.4.2.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
960
960
 
961
961
                        void ICollection.CopyTo (Array array, int index)
962
962
                        {
 
963
                                var target = array as TKey [];
 
964
                                if (target != null) {
 
965
                                        CopyTo (target, index);
 
966
                                        return;
 
967
                                }
 
968
 
963
969
                                IList list = array;
964
970
                                CopyToCheck (list, index);
 
971
 
965
972
                                for (int i = 0; i < dictionary.touchedSlots; i++) {
966
973
                                        if ((dictionary.linkSlots [i].HashCode & HASH_FLAG) != 0)
967
974
                                                list [index++] = dictionary.keySlots [i];
1035
1042
                                this.dictionary = dictionary;
1036
1043
                        }
1037
1044
 
 
1045
                        void CopyToCheck (IList array, int index)
 
1046
                        {
 
1047
                                if (array == null)
 
1048
                                        throw new ArgumentNullException ("array");
 
1049
                                if (index < 0)
 
1050
                                        throw new ArgumentOutOfRangeException ("index");
 
1051
                                // we want no exception for index==array.Length && dictionary.Count == 0
 
1052
                                if (index > array.Count)
 
1053
                                        throw new ArgumentException ("index larger than largest valid index of array");
 
1054
                                if (array.Count - index < dictionary.Count)
 
1055
                                        throw new ArgumentException ("Destination array cannot hold the requested elements!");
 
1056
                        }
 
1057
 
1038
1058
                        public void CopyTo (TValue [] array, int index)
1039
1059
                        {
1040
 
                                if (array == null)
1041
 
                                        throw new ArgumentNullException ("array");
1042
 
                                if (index < 0)
1043
 
                                        throw new ArgumentOutOfRangeException ("index");
1044
 
                                // we want no exception for index==array.Length && dictionary.Count == 0
1045
 
                                if (index > array.Length)
1046
 
                                        throw new ArgumentException ("index larger than largest valid index of array");
1047
 
                                if (array.Length - index < dictionary.Count)
1048
 
                                        throw new ArgumentException ("Destination array cannot hold the requested elements!");
 
1060
                                CopyToCheck (array, index);
1049
1061
 
1050
1062
                                for (int i = 0; i < dictionary.touchedSlots; i++) {
1051
1063
                                        if ((dictionary.linkSlots [i].HashCode & HASH_FLAG) != 0)
1085
1097
 
1086
1098
                        void ICollection.CopyTo (Array array, int index)
1087
1099
                        {
1088
 
                                CopyTo ((TValue []) array, index);
 
1100
                                var target = array as TValue [];
 
1101
                                if (target != null) {
 
1102
                                        CopyTo (target, index);
 
1103
                                        return;
 
1104
                                }
 
1105
 
 
1106
                                IList list = array;
 
1107
                                CopyToCheck (list, index);
 
1108
 
 
1109
                                for (int i = 0; i < dictionary.touchedSlots; i++) {
 
1110
                                        if ((dictionary.linkSlots [i].HashCode & HASH_FLAG) != 0)
 
1111
                                                list [index++] = dictionary.valueSlots [i];
 
1112
                                }
1089
1113
                        }
1090
1114
 
1091
1115
                        IEnumerator IEnumerable.GetEnumerator ()