Skip to content

Commit 94bc9e2

Browse files
Merge pull request #4678 from MicrosoftDocs/main638276311589663268sync_temp
For protected CLA branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 1707453 + 861950a commit 94bc9e2

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

docs/atl/reference/ccomdynamicunkarray-class.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CComDynamicUnkArray
3535
|[CComDynamicUnkArray::end](#end)|Returns a pointer to one past the last `IUnknown` pointer in the collection.|
3636
|[CComDynamicUnkArray::GetAt](#getat)|Retrieves the element at the specified index.|
3737
|[CComDynamicUnkArray::GetCookie](#getcookie)|Call this method to get the cookie associated with a given `IUnknown` pointer.|
38-
|[CComDynamicUnkArray::GetSize](#getsize)|Returns the length of an array.|
38+
|[CComDynamicUnkArray::GetSize](#getsize)|Returns the number of elements the array can store.|
3939
|[CComDynamicUnkArray::GetUnknown](#getunknown)|Call this method to get the `IUnknown` pointer associated with a given cookie.|
4040
|[CComDynamicUnkArray::Remove](#remove)|Call this method to remove an `IUnknown` pointer from the array.|
4141

@@ -69,7 +69,12 @@ The `IUnknown` pointer to add to the array.
6969

7070
### Return Value
7171

72-
Returns the cookie associated with the newly added pointer.
72+
Returns the cookie associated with the newly added pointer. Use this cookie to retrieve the pointer from the array with [CComDynamicUnkArray::GetAt](#getat).
73+
74+
### Remarks
75+
76+
The position where this item is inserted won't necessarily be directly after the last-inserted item if `Remove()` was previously called on this array. Use the returned cookie to reliably access the inserted pointer.
77+
The array's size might be increased to accommodate more items. Use `GetSize()` to get the new size.
7378

7479
## <a name="begin"></a> CComDynamicUnkArray::begin
7580

@@ -92,7 +97,7 @@ Before using the `IUnknown` interface, you should check that it is not NULL.
9297

9398
## <a name="clear"></a> CComDynamicUnkArray::clear
9499

95-
Empties the array.
100+
Empties the array. Resets the size to 0.
96101

97102
```cpp
98103
void clear();
@@ -124,7 +129,9 @@ Frees resources allocated by the class constructor.
124129

125130
## <a name="end"></a> CComDynamicUnkArray::end
126131

127-
Returns a pointer to one past the last `IUnknown` pointer in the collection.
132+
Returns a pointer to one-past the last element in the array's allocated buffer.
133+
134+
Note: this means that the last-inserted pointer is not guaranteed to be at `end()-1` because the array may not be filled to capacity.
128135

129136
```
130137
IUnknown**
@@ -150,7 +157,7 @@ The index of the element to retrieve.
150157

151158
### Return Value
152159

153-
A pointer to an [IUnknown](/windows/win32/api/unknwn/nn-unknwn-iunknown) interface.
160+
A pointer to an [IUnknown](/windows/win32/api/unknwn/nn-unknwn-iunknown) interface if an element was previously added and exists at this index; otherwise `NULL`.
154161

155162
## <a name="getcookie"></a> CComDynamicUnkArray::GetCookie
156163

@@ -175,17 +182,19 @@ If there is more than one instance of the same `IUnknown` pointer, this function
175182

176183
## <a name="getsize"></a> CComDynamicUnkArray::GetSize
177184

178-
Returns the length of an array.
185+
Returns the allocated capacity of the array.
186+
187+
Note: this is not the same as the number of non-NULL elements currently in the array.
179188

180189
```
181190
int GetSize() const;
182191
```
183192

184193
### Return Value
185194

186-
The length of the array.
195+
The number of elements the array can store. `GetSize() == end() - begin()`.
187196

188-
## <a name="getunknown"></a> CComDynamicUnkArray::GetUnknown
197+
## <a name="getunknown"></a> CComDynamicUnkArray::GetUnknown
189198

190199
Call this method to get the `IUnknown` pointer associated with a given cookie.
191200

@@ -206,6 +215,8 @@ Returns the `IUnknown` pointer, or NULL if no matching cookie is found.
206215

207216
Call this method to remove an `IUnknown` pointer from the array.
208217

218+
All other elements are unchanged and retain their index and cookie.
219+
209220
```
210221
BOOL Remove(DWORD dwCookie);
211222
```

0 commit comments

Comments
 (0)