本文整理汇总了C++中List::Begin方法的典型用法代码示例。如果您正苦于以下问题:C++ List::Begin方法的具体用法?C++ List::Begin怎么用?C++ List::Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List::Begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void test()
{
List<int> l;
for(int i = 0;i < 5;i++)
{
l.PushBack(i);
}
for (int i = 5;i < 10;i++)
{
l.PushFront(i);
}
List<int>::Iterator it = l.Begin();
while (it != l.End())
{
cout<<*it<<" ";
it++;
}
cout<<endl;
l.PopBack();
l.PopBack();
l.PopFront();
l.PopFront();
it = l.Begin();
while (it != l.End())
{
cout<<*it<<" ";
it++;
}
cout<<endl;
}
示例2: compareWithMyList
void compareWithMyList(List<int> &mylist, List<int> &flist) {
Iterator<int> iterator = mylist.Begin();
Iterator<int> iter = flist.Begin();
for(; iterator != mylist.End(); iterator++, iter++)
if(*iterator != *iter) {
std::cout << "Test error: Compare error" << std::endl;
return;
}
std::cout << "Test completed: Full compare" << std::endl;
}
示例3: FinishSpellCheckerService
ECode CTextServicesManagerService::FinishSpellCheckerService(
/* [in] */ ISpellCheckerSessionListener* listener)
{
if (!CalledFromValidUser()) {
return NOERROR;
}
if (DBG) {
Slogger::D(TAG, "FinishSpellCheckerService");
}
{
AutoLock lock(mSpellCheckerMapLock);
List<AutoPtr<SpellCheckerBindGroup> > removeList;
ManagedSpellCheckerBindGroupMapIt it = mSpellCheckerBindGroups.Begin();
for (; it != mSpellCheckerBindGroups.End(); ++it) {
AutoPtr<SpellCheckerBindGroup> group = it->mSecond;
if (group == NULL) continue;
removeList.PushBack(group);
}
List<AutoPtr<SpellCheckerBindGroup> >::Iterator it2 = removeList.Begin();
for (; it2 != removeList.End(); ++it2) {
((*it2).Get())->RemoveListener(listener);
}
removeList.Clear();
}
return NOERROR;
}
示例4: Transform
bool TestList2()
{
List l;
l.PushBack(-1);
l.PushBack(0);
l.PushBack(1);
l.PushBack(2);
l.PushBack(3);
l.PushBack(4);
l.PushBack(5);
l.PushBack(6);
l.PushBack(7);
l.PushBack(8);
l.PushBack(9);
l.PopFront();
int result[10] = {0};
int* i = Transform(l.Begin(), l.End(), Square, result);
if(i != result + 10)
return false;
if(!CheckResult(result))
return false;
return true;
}
示例5: FormatToCharacterIterator
ECode MessageFormat::FormatToCharacterIterator(
/* [in] */ IInterface* object,
/* [out] */ IAttributedCharacterIterator** characterIterator)
{
VALIDATE_NOT_NULL(characterIterator);
*characterIterator = NULL;
VALIDATE_NOT_NULL(object);
StringBuffer buffer;
List<AutoPtr<FieldContainer> > fields;
// format the message, and find fields
AutoPtr<IFieldPosition> position;
CFieldPosition::New(0, (IFieldPosition**)&position);
AutoPtr<ArrayOf<IInterface*> > arr = ArrayOf<IInterface*>::Alloc(1);
arr->Set(0, object);
FormatImpl(arr, &buffer, position, &fields);
// create an AttributedString with the formatted buffer
AutoPtr<IAttributedString> as;
String outstr;
buffer.Substring(0, buffer.GetLength(),&outstr);
CAttributedString::New(outstr, (IAttributedString**)&as);
// add MessageFormat field attributes and values to the AttributedString
List<AutoPtr<FieldContainer> >::Iterator fc = fields.Begin();
for ( ; fc != fields.End(); ++fc) {
FAIL_RETURN(as->AddAttribute((*fc)->mAttribute, (*fc)->mValue, (*fc)->mStart, (*fc)->mEnd));
}
// return the CharacterIterator from AttributedString
return as->GetIterator(characterIterator);
}
示例6:
bool operator == (const List<T>& x1, const List<T>& x2)
{
typename List<T>::ConstIterator i1, i2;
for (
i1 = x1.Begin(), i2 = x2.Begin();
(i1 != x1.End()) && (i2 != x2.End());
++i1, ++i2
)
{
if (*(i1) != *(i2))
return 0;
}
if (i1 != x1.End() || i2 != x2.End())
return 0;
return 1;
}
示例7: EnablePendingListeners
void Observer::EnablePendingListeners()
{
List<AutoPtr<IObserverListener> > pendingListeners;
{
AutoLock lock(this);
List<AutoPtr<WrappedListener> >::Iterator it;
for (it = mListeners.Begin(); it != mListeners.End(); ++it) {
if (!(*it)->mEnabled) {
pendingListeners.PushBack((*it)->mListener);
(*it)->mEnabled = TRUE;
}
}
}
/* we have threading guarantees from the Core that the proxies set will not change
* during this call. Therefore, we don't need to do anything special to safeguard
* proxies during iteration. */
AutoPtr<ICollection> collection;
mProxies->GetValues((ICollection**)&collection);
List<AutoPtr<IObserverListener> >::Iterator it;
for (it = pendingListeners.Begin(); it != pendingListeners.End(); ++it) {
AutoPtr<IIterator> pit;
collection->GetIterator((IIterator**)&pit);
Boolean hasNext;
while (pit->HasNext(&hasNext), hasNext) {
AutoPtr<IInterface> obj;
pit->GetNext((IInterface**)&obj);
(*it)->ObjectDiscovered(IProxyBusObject::Probe(obj));
}
}
}
示例8: GetSerialPorts
ECode CSerialService::GetSerialPorts(
/* [out, callee] */ ArrayOf<String>** serialPorts)
{
FAIL_RETURN(mContext->EnforceCallingOrSelfPermission(Elastos::Droid::Manifest::Permission::SERIAL_PORT, String(NULL)));
List<String> ports;
Int32 length = mSerialPorts->GetLength();
for (Int32 i = 0; i < length; i++) {
String path((*mSerialPorts)[i]);
AutoPtr<IFile> file;
CFile::New(path, (IFile**)&file);
Boolean isExist;
file->Exists(&isExist);
if (isExist) {
ports.PushBack(path);
}
}
*serialPorts = ArrayOf<String>::Alloc(ports.GetSize());
REFCOUNT_ADD(*serialPorts);
List<String>::Iterator it = ports.Begin();
for (Int32 i = 0; it != ports.End(); ++it, i++) {
(**serialPorts)[i] = *it;
}
return NOERROR;
}
示例9: PrintList2
void PrintList2(const List<int>& l1)
{
List<int>::ConstIterator it = l1.Begin();
for (; it != l1.End(); ++it)
{
cout<<*it<<" ";
}
cout<<endl;
}
示例10: UpdateLocked
/**
* Updates the state of the logical display based on the available display devices.
* The logical display might become invalid if it is attached to a display device
* that no longer exists.
*
* @param devices The list of all connected display devices.
*/
void LogicalDisplay::UpdateLocked(
/* [in] */ const List< AutoPtr<DisplayDevice> >& devices)
{
// Nothing to update if already invalid.
if (mPrimaryDisplayDevice == NULL) {
return;
}
// Check whether logical display has become invalid.
if (Find(devices.Begin(), devices.End(), mPrimaryDisplayDevice) == devices.End()) {
mPrimaryDisplayDevice = NULL;
return;
}
// Bootstrap the logical display using its associated primary physical display.
// We might use more elaborate configurations later. It's possible that the
// configuration of several physical displays might be used to determine the
// logical display that they are sharing. (eg. Adjust size for pixel-perfect
// mirroring over HDMI.)
AutoPtr<DisplayDeviceInfo> deviceInfo = mPrimaryDisplayDevice->GetDisplayDeviceInfoLocked();
if ((mPrimaryDisplayDeviceInfo == NULL && deviceInfo != NULL) || !mPrimaryDisplayDeviceInfo->Equals(deviceInfo)) {
mBaseDisplayInfo->SetLayerStack(mLayerStack);
mBaseDisplayInfo->SetFlags(0);
if ((deviceInfo->mFlags & DisplayDeviceInfo::FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) {
Int32 flags;
mBaseDisplayInfo->GetFlags(&flags);
flags |= IDisplay::FLAG_SUPPORTS_PROTECTED_BUFFERS;
mBaseDisplayInfo->SetFlags(flags);
}
if ((deviceInfo->mFlags & DisplayDeviceInfo::FLAG_SECURE) != 0) {
Int32 flags;
mBaseDisplayInfo->GetFlags(&flags);
flags |= IDisplay::FLAG_SECURE;
mBaseDisplayInfo->SetFlags(flags);
}
mBaseDisplayInfo->SetType(deviceInfo->mType);
mBaseDisplayInfo->SetAddress(deviceInfo->mAddress);
mBaseDisplayInfo->SetName(deviceInfo->mName);
mBaseDisplayInfo->SetAppWidth(deviceInfo->mWidth);
mBaseDisplayInfo->SetAppHeight(deviceInfo->mHeight);
mBaseDisplayInfo->SetLogicalWidth(deviceInfo->mWidth);
mBaseDisplayInfo->SetLogicalHeight(deviceInfo->mHeight);
mBaseDisplayInfo->SetRotation(ISurface::ROTATION_0);
mBaseDisplayInfo->SetRefreshRate(deviceInfo->mRefreshRate);
mBaseDisplayInfo->SetLogicalDensityDpi(deviceInfo->mDensityDpi);
mBaseDisplayInfo->SetPhysicalXDpi(deviceInfo->mXDpi);
mBaseDisplayInfo->SetPhysicalYDpi(deviceInfo->mYDpi);
mBaseDisplayInfo->SetSmallestNominalAppWidth(deviceInfo->mWidth);
mBaseDisplayInfo->SetSmallestNominalAppHeight(deviceInfo->mHeight);
mBaseDisplayInfo->SetLargestNominalAppWidth(deviceInfo->mWidth);
mBaseDisplayInfo->SetLargestNominalAppHeight(deviceInfo->mHeight);
mPrimaryDisplayDeviceInfo = deviceInfo;
mInfo = NULL;
}
}
示例11: ObjectDiscovered
void Observer::ObjectDiscovered(
/* [in] */ const String& busname,
/* [in] */ const String& path,
/* [in] */ ArrayOf<String>* interfaces,
/* [in] */ Int32 sessionId)
{
if (DEBUG) {
Logger::I(TAG, " >> ObjectDiscovered: busname: %s, path: %s, sessionId: %08x", busname.string(), path.string(), sessionId);
for (Int32 i = 0; i < interfaces->GetLength(); ++i) {
Logger::I(TAG, " > interface %d: %s", i, (*interfaces)[i].string());
}
}
List<AutoPtr<IInterfaceInfo> > intfList;
HashMap<String, AutoPtr<IInterfaceInfo> >::Iterator mit;
for (Int32 i = 0; i < interfaces->GetLength(); ++i) {
mit = mInterfaceMap.Find((*interfaces)[i]);
if (mit != mInterfaceMap.End()) {
intfList.PushBack(mit->mSecond);
}
}
//TODO figure out what to do with secure bus objects
Int32 i = 0;
AutoPtr<ArrayOf<IInterfaceInfo*> > infos = ArrayOf<IInterfaceInfo*>::Alloc(intfList.GetSize());
List<AutoPtr<IInterfaceInfo> >::Iterator lit;
for (lit = intfList.Begin(); lit != intfList.End(); ++lit) {
infos->Set(i++, *lit);
}
AutoPtr<IProxyBusObject> proxy;
mBus->GetProxyBusObject(busname, path, sessionId, infos, (IProxyBusObject**)&proxy);
AutoPtr< List<AutoPtr<WrappedListener> > > copiedListeners;
{
AutoLock lock(this);
AutoPtr<ObjectId> oid = new ObjectId(busname, path);
mProxies->Put(TO_IINTERFACE(oid), proxy);
copiedListeners = new List<AutoPtr<WrappedListener> >(mListeners);
}
/* we do the listener invocation outside of the critical region to avoid
* lock ordering issues */
List<AutoPtr<WrappedListener> >::Iterator wit;
for (wit = copiedListeners->Begin(); wit != copiedListeners->End(); ++wit) {
if ((*wit)->mEnabled) {
// protect against exceptions in listener code.
if (DEBUG) {
Logger::I(TAG, " >> %s ObjectDiscovered: %s", TO_CSTR((*wit)->mListener), TO_CSTR(proxy));
}
(*wit)->mListener->ObjectDiscovered(proxy);
}
}
}
示例12: compareWithStlList
void compareWithStlList(List<int> &mylist, std::list<int> &slist) {
Iterator<int> iterator = mylist.Begin();
std::list<int>::iterator iter = slist.begin();
for(; iter != slist.end(); iterator++, iter++)
if(*iterator != *iter) {
std::cout << "Test error: Compare error" << std::endl;
return;
}
std::cout << "Test completed: Full compare" << std::endl;
}
示例13:
List<GameObject*> GameObject::GetChildrenRecursivelyEditor() const
{
List<GameObject*> cc;
for (GameObject *c : m_children)
{
List<GameObject*> childChildren = c->GetChildrenRecursivelyEditor();
cc.Splice(cc.Begin(), childChildren);
cc.PushBack(c);
}
return cc;
}
示例14:
AutoPtr<IObjectContainer> ActivityChooserModel::TransfromList(
/* [in] */ List<AutoPtr<T> >& list)
{
AutoPtr<IObjectContainer> container;
CObjectContainer::New((IObjectContainer**)&container);
typename List<AutoPtr<T> >::Iterator it = list.Begin();
for(; it != list.End(); it++)
{
container->Add(*it);
}
return container;
}
示例15: PushRenderer
void RenderQueue::PushRenderer(const List<SceneNode *> & nodes)
{
List<SceneNode *>::ConstIterator whr = nodes.Begin();
List<SceneNode *>::ConstIterator end = nodes.End();
while (whr != end)
{
_pushRenderer(*whr);
++whr;
}
}