Changeset 16742 in vbox
- Timestamp:
- Feb 13, 2009 3:21:11 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42783
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/array.h
r16671 r16742 755 755 * existing value to the array element, for example: 756 756 * <tt>Bstr string; array.push_back (string);</tt>. If you create a string 757 * just to put it tothe array, you may find #appendedRaw() more useful.757 * just to put it in the array, you may find #appendedRaw() more useful. 758 758 * 759 759 * @param aElement Element to append. 760 760 * 761 * @return @c true on success and false if there is not enough761 * @return @c true on success and @c false if there is not enough 762 762 * memory for resizing. 763 763 */ … … 789 789 * 790 790 * This method is handy for operations like 791 * <tt>Bstr ("foo").detac To (array.appendedRaw());</tt>. Don't use it as792 * l-value (<tt>array.appendedRaw() = SysAllocString (L"tralala");</tt>)791 * <tt>Bstr ("foo").detachTo (array.appendedRaw());</tt>. Don't use it as 792 * an l-value (<tt>array.appendedRaw() = SysAllocString (L"tralala");</tt>) 793 793 * since this doesn't check for a NULL condition; use #resize() and 794 794 * #setRawAt() instead. If you need to assign a copy of the existing value … … 815 815 /** 816 816 * Resizes the array preserving its contents when possible. If the new size 817 * is large tthan the old size, new elements are initialized with null817 * is larger than the old size, new elements are initialized with null 818 818 * values. If the new size is less than the old size, the contents of the 819 819 * array beyond the new size is lost. 820 820 * 821 821 * @param aNewSize New number of elements in the array. 822 * @return @c true on success and false if there is not enough822 * @return @c true on success and @c false if there is not enough 823 823 * memory for resizing. 824 824 */ … … 850 850 * 851 851 * @param aNewSize New number of elements in the array. 852 * @return @c true on success and false if there is not enough852 * @return @c true on success and @c false if there is not enough 853 853 * memory for resizing. 854 854 */ … … 933 933 * @note It is assumed that the ownership of the returned copy is 934 934 * transferred to the caller of the method and he is responsible to free the 935 * array data when it is no more necessary.935 * array data when it is no longer needed. 936 936 * 937 937 * @param aArg Output method parameter to clone to. … … 963 963 * @note Since the ownership of the array data is transferred to the 964 964 * caller of the method, he is responsible to free the array data when it is 965 * no more necessary.965 * no longer needed. 966 966 * 967 967 * @param aArg Location to detach to. … … 1003 1003 } 1004 1004 1005 // public methods for internal purposes only1005 // Public methods for internal purposes only. 1006 1006 1007 1007 #if defined (VBOX_WITH_XPCOM) … … 1031 1031 1032 1032 /** 1033 * Ensures that the array is big enough to conta on aNewSize elements.1033 * Ensures that the array is big enough to contain aNewSize elements. 1034 1034 * 1035 1035 * If the new size is greater than the current capacity, a new array is 1036 * allocated and elements from the old array are copied over. The 1036 * allocated and elements from the old array are copied over. The size of 1037 1037 * the array doesn't change, only the capacity increases (which is always 1038 1038 * greater than the size). Note that the additionally allocated elements are … … 1062 1062 return true; 1063 1063 1064 /* allocate in 16-byte pieces*/1064 /* Allocate in 16-byte pieces. */ 1065 1065 size_t newCapacity = RT_MAX ((aNewSize + 15) / 16 * 16, 16); 1066 1066 … … 1074 1074 if (m.size > aNewSize) 1075 1075 { 1076 /* truncation takes place, uninit exceeding elements and1077 * shrink the size */1076 /* Truncation takes place, uninit exceeding elements and 1077 * shrink the size. */ 1078 1078 for (size_t i = aNewSize; i < m.size; ++ i) 1079 1079 Uninit (m.arr [i]); … … 1082 1082 } 1083 1083 1084 /* copy the old contents*/1084 /* Copy the old contents. */ 1085 1085 memcpy (newArr, m.arr, m.size * sizeof (T)); 1086 1086 nsMemory::Free ((void *) m.arr); … … 1093 1093 if (m.size > aNewSize) 1094 1094 { 1095 /* truncation takes place, uninit exceeding elements and1096 * shrink the size */1095 /* Truncation takes place, uninit exceeding elements and 1096 * shrink the size. */ 1097 1097 for (size_t i = aNewSize; i < m.size; ++ i) 1098 1098 Uninit (m.arr [i]); … … 1221 1221 * ComSafeArrayIn* and ComSafeArrayOut*. Another important nuance is that the 1222 1222 * raw() array type is different (nsID **, or GUID ** on XPCOM and GUID * on MS 1223 * COM) so it is recommended to use operator[] instead thatalways returns a1223 * COM) so it is recommended to use operator[] instead which always returns a 1224 1224 * GUID by value. 1225 1225 * … … 1277 1277 /** 1278 1278 * Array access operator that returns an array element by reference. As a 1279 * special case, the return value of this operator on XPCOM is a nsID (GUID)1280 * reference, instead of a nsID pointer (the actual SafeArray template1279 * special case, the return value of this operator on XPCOM is an nsID (GUID) 1280 * reference, instead of an nsID pointer (the actual SafeArray template 1281 1281 * argument), for compatibility with the MS COM version. 1282 1282 * … … 1337 1337 private: 1338 1338 1339 /* These are disabled because of const */1339 /* These are disabled because of const. */ 1340 1340 bool reset (size_t aNewSize) { NOREF (aNewSize); return false; } 1341 1341 }; … … 1461 1461 * 1462 1462 * Note that this constructor doesn't take the ownership of the array. In 1463 * particular, it means that operations that operate on the ownership (e.g.1464 * #detachTo()) are forbidden and will assert.1463 * particular, this means that operations that operate on the ownership 1464 * (e.g. #detachTo()) are forbidden and will assert. 1465 1465 * 1466 1466 * @param aArg Input method parameter to attach to.
Note:
See TracChangeset
for help on using the changeset viewer.