本文整理汇总了C++中AutoPtr::AddAll方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::AddAll方法的具体用法?C++ AutoPtr::AddAll怎么用?C++ AutoPtr::AddAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::AddAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAllAddresses
ECode LinkProperties::GetAllAddresses(
/* [out] */ IList** result)
{
VALIDATE_NOT_NULL(result)
AutoPtr<IList> addresses;
CArrayList::New((IList**)&addresses);
AutoPtr<IIterator> it;
mLinkAddresses->GetIterator((IIterator**)&it);
Boolean hasNext;
while (it->HasNext(&hasNext), hasNext) {
AutoPtr<IInterface> obj;
it->GetNext((IInterface**)&obj);
AutoPtr<IInetAddress> address;
ILinkAddress::Probe(obj)->GetAddress((IInetAddress**)&address);
addresses->Add(address);
}
AutoPtr<ICollection> links;
mStackedLinks->GetValues((ICollection**)&links);
it = NULL;
links->GetIterator((IIterator**)&it);
while (it->HasNext(&hasNext), hasNext) {
AutoPtr<IInterface> obj;
it->GetNext((IInterface**)&obj);
AutoPtr<IList> allAddresses;
ILinkProperties::Probe(obj)->GetAllAddresses((IList**)&allAddresses);
addresses->AddAll(ICollection::Probe(allAddresses));
}
*result = addresses;
REFCOUNT_ADD(*result)
return NOERROR;
}
示例2: AddProfileInternal
void ProfileManagerService::AddProfileInternal(
/* [in] */ IProfile* profile)
{
// Make sure this profile has all of the correct groups.
AutoPtr<ICollection> values;
mGroups->GetValues((ICollection**)&values);
AutoPtr<IArrayList> arrayList;
CArrayList::New((IArrayList**)&arrayList);
Boolean flag = FALSE;
arrayList->AddAll(values, &flag);
Int32 size;
arrayList->GetSize(&size);
AutoPtr<IInterface> obj;
AutoPtr<INotificationGroup> group;
for (Int32 i = 0; i < size; ++i) {
obj = NULL;
arrayList->Get(i, (IInterface**)&obj);
group = INotificationGroup::Probe(obj);
EnsureGroupInProfile(profile, group.Get(), FALSE);
}
EnsureGroupInProfile(profile, mWildcardGroup.Get(), true);
AutoPtr<IUUID> uuid;
profile->GetUuid((IUUID**)&uuid);
mProfiles->Put(uuid, profile);
String name;
profile->GetName(&name);
mProfileNames->Put(StringUtils::ParseCharSequence(name).Get(), uuid.Get());
mDirty = TRUE;
}
示例3:
AutoPtr<IProfile> ProfileManagerService::GetProfile(
/* [in] */ IUUID* profileUuid)
{
// use primary UUID first
Boolean flag = FALSE;
mProfiles->ContainsKey(profileUuid, &flag);
AutoPtr<IProfile> profile;
AutoPtr<IInterface> obj;
if (flag) {
mProfiles->Get(profileUuid, (IInterface**)&obj);
profile = IProfile::Probe(obj);
return profile;
}
// if no match was found: try secondary UUID
AutoPtr<ICollection> collection;
mProfiles->GetValues((ICollection**)&collection);
AutoPtr<IArrayList> list;
CArrayList::New((IArrayList**)&list);
list->AddAll(collection.Get());
Int32 size;
list->GetSize(&size);
AutoPtr<IProfile> p;
AutoPtr<ArrayOf<IUUID*> > uuids;
AutoPtr<IUUID> uuid;
for (Int32 i = 0; i < size; ++i) {
obj = NULL;
p = NULL;
p = IProfile::Probe(obj);
uuids = NULL;
p->GetSecondaryUuids((ArrayOf<IUUID*>**)&uuids);
Int32 length = uuids->GetLength();
for (Int32 j = 0; j < length; ++j) {
uuid = NULL;
uuid = (*uuids)[j];
profileUuid->Equals(uuid, &flag);
if (flag) return p;
}
}
// nothing found
return NULL;
}
示例4: test_addAllLjava_util_Collection
int CTest::test_addAllLjava_util_Collection(int argc, char* argv[])
{
PEL("CTest::test_addAllLjava_util_Collection")
// Test for method boolean
// java.util.ArrayList.addAll(java.util.Collection)
AutoPtr<IArrayList> l;
CArrayList::New((IArrayList**)&l);
Boolean isflag = FALSE;
l->AddAll(alist, &isflag);
Int32 sizelen = 0;
AutoPtr<IInterface> outface;
AutoPtr<IInterface> outface2;
for (int i = 0; i < (alist->GetSize(&sizelen), sizelen); i++) {
l->Get(i, (IInterface**)&outface);
alist->Get(i, (IInterface**)&outface2);
assert(outface == outface2);
}
alist->AddAll(alist, &isflag);
assert(200 == (alist->GetSize(&sizelen), sizelen));
for (int i = 0; i < 100; i++) {
alist->Get(i, (IInterface**)&outface);
l->Get(i, (IInterface**)&outface2);
assert(outface == outface2);
alist->Get(i + 100, (IInterface**)&outface);
assert(outface == outface2);
}
// AutoPtr<ISet> setWithNulls;
// CHashSet::New((ISet**)&setWithNulls);
// setWithNulls->Add(NULL, &isflag);
// setWithNulls->Add(NULL, &isflag);
// setWithNulls->Add(youink, &isflag);
// setWithNulls->Add(kazoo, &isflag);
// setWithNulls->Add(NULL, &isflag);
// alist->AddAllEx(100, setWithNulls, &isflag);
// AutoPtr<IIterator> i;
// setWithNulls->GetIterator((IIterator**)&i);
// alist->Get(100, (IInterface**)&outface);
// i->Next((IInterface**)&outface2);
// assert(outface == outface2);
// alist->Get(101, (IInterface**)&outface);
// i->Next((IInterface**)&outface2);
// assert(outface == outface2);
// alist->Get(102, (IInterface**)&outface);
// i->Next((IInterface**)&outface2);
// assert(outface == outface2);
// Regression test for Harmony-3481
AutoPtr<IArrayList> originalList;
CArrayList::New(12, (IArrayList**)&originalList);
for (int j = 0; j < 12; j++) {
AutoPtr<IInteger32> intface;
CInteger32::New(j, (IInteger32**)&intface);
originalList->Add(intface, &isflag);
}
AutoPtr<IInteger32> intface;
originalList->RemoveEx(0, (IInterface**)&outface);
originalList->RemoveEx(0, (IInterface**)&outface);
AutoPtr<IArrayList> additionalList;
CArrayList::New(11, (IArrayList**)&additionalList);
for (int j = 0; j < 11; j++) {
CInteger32::New(j, (IInteger32**)&intface);
additionalList->Add(intface, &isflag);
}
assert((originalList->AddAll(additionalList, &isflag), isflag));
assert(21 == (originalList->GetSize(&sizelen), sizelen));
// try {
ECode ec = alist->AddAll(NULL, &isflag);
if (ec != NOERROR) {
printf("NullPointerException expected\n");
}
// } catch (NullPointerException e) {
//expected
// }
return 0;
}