ECode AttributedString::AttributedIterator::GetAllAttributeKeys( /* [out] */ ISet** allAttributedKeys) { VALIDATE_NOT_NULL(allAttributedKeys); AutoPtr<ISet> result; CHashSet::New((ISet**)&result); ICollection* ci = ICollection::Probe(result); *allAttributedKeys = result; REFCOUNT_ADD(*allAttributedKeys); AttributeRangeMapIterator it = mAttrString->mAttributeMap.Begin(); if (mBegin == 0 && mEnd == (Int32)mAttrString->mText.GetLength() && mAttributesAllowed.IsEmpty()) { for(; it != mAttrString->mAttributeMap.End(); ++it) { ci->Add(it->mFirst); } return NOERROR; } for(; it != mAttrString->mAttributeMap.End(); ++it) { if (mAttributesAllowed.Find(it->mFirst) != mAttributesAllowed.End()) { AutoPtr<List<AutoPtr<Range> > > ranges = it->mSecond; if (InRange(ranges)) { ci->Add(it->mFirst); } } } return NOERROR; }
BOOL CConfigurationDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // create available device list. SetControlWinText(0); SetControlText(3202, 2) ; InstantDiCtrl * instantDiCtrl = AdxInstantDiCtrlCreate(); ICollection<DeviceTreeNode>* sptedDevices = instantDiCtrl->getSupportedDevices(); if (sptedDevices->getCount() == 0) { GetDlgItem(IDOK)->EnableWindow(FALSE); GetDlgItem(IDCANCEL)->EnableWindow(FALSE); AfxMessageBox(_T("No device to support the currently demonstrated function!")); return FALSE; }else{ for (int i = 0; i < sptedDevices->getCount(); ++i) { DeviceTreeNode const & node = sptedDevices->getItem(i); TRACE("%d, %s\n", node.DeviceNumber, node.Description); TCHAR des[MAX_DEVICE_DESC_LEN]; m_comboBox_Device.AddString(WCHAR_TO_TCHAR(node.Description,des)); m_comboBox_Device.SetItemData(i,node.DeviceNumber); } sptedDevices->Dispose(); } instantDiCtrl->Dispose(); m_comboBox_Device.SetCurSel(0); return TRUE; }
//! split string into parts. void stringc::split(ICollection<stringc>& ret, const c8* const c, u32 count, bool ignoreEmptyTokens, bool keepSeparators) const { IRR_ASSERT(c != 0); u32 lastpos = 0; bool lastWasSeparator = false; for (u32 i = 0; i < Used; ++i) { bool foundSeparator = false; for (u32 j = 0; j < count; ++j) { if (Array[i] == c[j]) { if ((!ignoreEmptyTokens || i - lastpos != 0) && !lastWasSeparator) ret.pushBack(stringc(&Array[lastpos], i - lastpos)); foundSeparator = true; lastpos = (keepSeparators ? i : i + 1); break; } } lastWasSeparator = foundSeparator; } if ((Used - 1) > lastpos) ret.pushBack(stringc(&Array[lastpos], (Used - 1) - lastpos)); }
void dump (const char* collection_name, const ICollection<Item>& collection, int level) { print_space (level++); printf ("Collection '%s' (%u items)\n", collection_name, collection.Size ()); for (typename ICollection<Item>::ConstIterator i=collection.CreateIterator (); i; ++i) dump (*i, level); }
SingleLinkedList::SingleLinkedList(const ICollection& other) { size = other.getNumElements(); auto it = other.getIterator(); while (it->current() != nullptr) { m_first = new ListEntry(m_first, it->current()); it->next(); } }
bool IMesh::TryUpdateVertex(VertexGraphicsBuffer& bufferObject, size_t vertexIndex, const ICollection<Point3F>& vertices, const Matrix4& matrix) const { RETURN_TRUE_IF_EMPTY(vertices); bufferObject.ReserveSize(vertexIndex, vertices.Count()); size_t count = vertices.Count(); const Point3F* verticesPtr = vertices.Items(); FOR_EACH_SIZE(i, count) { Point3F pos = matrix.Transform(verticesPtr[i]); bufferObject.AppendOrUpdateData(vertexIndex + i, pos); }
void ReadHardware::init() { // select a device by device number or device description and specify the access mode. DeviceInformation devInfo(deviceDescription); ret = instantDiCtrl->setSelectedDevice(devInfo); if( ret != Success) { throw LzException(1, "initialize hardware failed"); } // 设置该端口为输入模式 ICollection<PortDirection>* portDirection = instantDiCtrl->getPortDirection(); portDirection->getItem(m_nPortNum).setDirection(Input); }
ArrayList(const ICollection<T>& other) { m_numElements = other.getNumElements(); capacity = 2*(m_numElements); data = new T[capacity]; int i = 0; auto it = other.getIterator(); while (it->current() != nullptr) { data[i] = *it->current(); it->next(); ++i; } }
ECode AttributedString::constructor( /* [in] */ IAttributedCharacterIterator* iterator, /* [in] */ Int32 start, /* [in] */ Int32 end, /* [in] */ ArrayOf<IAttributedCharacterIteratorAttribute*>* attributes) { AutoPtr<ISet> container; CHashSet::New((ISet**)&container); if (attributes != NULL) { Boolean modified; ICollection* collection = ICollection::Probe(container); for (Int32 i = 0; i < attributes->GetLength(); ++i) { collection->Add((*attributes)[i], &modified); } } return constructor(iterator, start, end, container); }
ECode AttributedString::constructor( /* [in] */ const String& value, /* [in] */ IMap* attributes) { VALIDATE_NOT_NULL(attributes); if (value.IsNull()) { // throw new NullPointerException("value == null"); return E_NULL_POINTER_EXCEPTION; } ICollection* c = ICollection::Probe(attributes); assert(c != NULL); Boolean empty; c->IsEmpty(&empty); if (value.IsEmpty() && !empty) { // throw new IllegalArgumentException("Cannot add attributes to empty string"); return E_ILLEGAL_ARGUMENT_EXCEPTION; } mText = value; AutoPtr<IIterator> it; IIterable::Probe(attributes)->GetIterator((IIterator**)&it); AutoPtr<List<AutoPtr<Range> > > ranges; IAttributedCharacterIteratorAttribute* attr; Boolean hasNext; while (it->HasNext(&hasNext), hasNext) { AutoPtr<IInterface> obj;; it->GetNext((IInterface**)&obj); IMapEntry* entry = IMapEntry::Probe(obj); AutoPtr<IInterface> val; entry->GetValue((IInterface**)&val); AutoPtr<IInterface> key; entry->GetKey((IInterface**)&key); ranges = new List<AutoPtr<Range> >(1); AutoPtr<Range> range = new Range(0, value.GetLength(), val); ranges->PushBack(range); attr = IAttributedCharacterIteratorAttribute::Probe(key); mAttributeMap[attr] = ranges; } return NOERROR; }
IINField RestartOperationTask::ProcessHeader(const CountHeader& header, const ICollection<Group52Var2>& values) { Group52Var2 value; if (values.ReadOnlyValue(value)) { this->m_duration = TimeDuration::Milliseconds(value.time); return IINField::Empty(); } else { return IINBit::PARAM_ERROR; } }
IINField LoggingHandler::PrintOctets(const ICollection<Indexed<OctetString>>& items) { Indent i(*callbacks); auto logItem = [this](const Indexed<OctetString>& item) { auto slice = item.value.ToRSlice(); FORMAT_LOG_BLOCK(logger, flags::APP_OBJECT_RX, "[%u] value: (length = %u)", item.index, slice.Size()); FORMAT_HEX_BLOCK(logger, flags::APP_OBJECT_RX, slice, 18, 18); }; items.ForeachItem(logItem); return IINField::Empty(); }
IINField LoggingHandler::ProcessHeader(const CountHeader& header, const ICollection<Group120Var4>& values) { Indent i(*callbacks); auto print = [this](const Group120Var4 & value) { std::ostringstream oss; oss << "user: " << value.userNum; SIMPLE_LOG_BLOCK(logger, flags::APP_OBJECT_RX, oss.str().c_str()); }; values.ForeachItem(print); return IINField::Empty(); }
IINField LoggingHandler::PrintTimeAndInterval(const ICollection<Indexed<TimeAndInterval>>& values) { Indent i(*callbacks); auto logItem = [this](const Indexed<TimeAndInterval>& item) { std::ostringstream oss; oss << "[" << item.index << "] - startTime: " << ToUTCString(item.value.time); oss << " count: " << item.value.interval; oss << " units: " << IntervalUnitsToString(item.value.GetUnitsEnum()) << " (" << static_cast<int>(item.value.units) << ")"; SIMPLE_LOG_BLOCK(logger, flags::APP_OBJECT_RX, oss.str().c_str()); }; values.ForeachItem(logItem); return IINField::Empty(); }
IINField LoggingHandler::ProcessHeader(const PrefixHeader& header, const ICollection<Indexed<Group122Var2>>& values) { Indent i(*callbacks); auto logItem = [this](const Indexed<Group122Var2>& item) { std::ostringstream oss; oss << "[" << item.index << "] - flags: 0x" << ToHex(item.value.flags); oss << " assoc: " << item.value.assocId; oss << " value: " << item.value.value; oss << " time: " << ToUTCString(item.value.time); SIMPLE_LOG_BLOCK(logger, flags::APP_OBJECT_RX, oss.str().c_str()); }; values.ForeachItem(logItem); return IINField::Empty(); }
IINField LoggingHandler::PrintCrob(const ICollection<Indexed<ControlRelayOutputBlock>>& items) { Indent i(*callbacks); auto logItem = [this](const Indexed<ControlRelayOutputBlock>& item) { std::ostringstream oss; oss << "[" << item.index << "] - code: 0x" << ToHex(item.value.rawCode) << " (" << ControlCodeToString(item.value.functionCode) << ")"; oss << " count: " << static_cast<uint32_t>(item.value.count); oss << " on-time: " << static_cast<uint32_t>(item.value.onTimeMS); oss << " off-time: " << static_cast<uint32_t>(item.value.offTimeMS); oss << " status: " << CommandStatusToString(item.value.status); SIMPLE_LOG_BLOCK(logger, flags::APP_OBJECT_RX, oss.str().c_str()); }; items.ForeachItem(logItem); return IINField::Empty(); }
IINField LoggingHandler::ProcessHeader(const PrefixHeader& header, const ICollection<Indexed<AnalogCommandEvent>>& values) { Indent i(*callbacks); const bool HAS_TIME = HasAbsoluteTime(header.enumeration); auto logItem = [this, HAS_TIME](const Indexed<AnalogCommandEvent>& item) { std::ostringstream oss; oss << "[" << item.index << "] - value: " << item.value.value << " status: " << CommandStatusToString(item.value.status); if (HAS_TIME) { oss << " time: " << ToUTCString(item.value.time); } SIMPLE_LOG_BLOCK(logger, flags::APP_OBJECT_RX, oss.str().c_str()); }; values.ForeachItem(logItem); return IINField::Empty(); }
// Sugiere una materia de las asignaturas seleccionadas tal que algun Estudiante haya aprobada. // En caso que no exista se retorna un ICollection vacio (List). IDictionary *Criterio2::devolverListaAsignatura(IDictionary* asigsUsuario) { // pedimos los estudiantes al manejador y vamos recorriendo uno a uno hasta encontrar alguno que tenga materias // aprobadas, en ese caso retornamos esa lista ManejadorEstudiante *eMgr = ManejadorEstudiante::getInstance(); IDictionary *e = eMgr->getEstudiantes(); bool found = false; ICollection *aprobadas; IDictionary *asignaturasNuevas = new OrderedDictionary(); IIterator * it = e->getIterator(); Estudiante *est; ICollectible *col; ICollectible *col2; ICollectible *col3; while(it->hasCurrent() && !found) { col = it->getCurrent(); if ((est = dynamic_cast<Estudiante*> (col)) != NULL) { if(est->getAprobadas() != NULL) { aprobadas = est->getAprobadas(); IIterator * it2 = aprobadas->getIterator(); while(it2->hasCurrent() && !found) { col2 = it2->getCurrent(); Aprobacion* apro; if ((apro = dynamic_cast<Aprobacion*> (col2)) != NULL) { Asignatura* asig = apro->getAsignatura(); IIterator * it3 = asigsUsuario->getIterator(); while(it3->hasCurrent() && !found) { col3 = it3->getCurrent(); Asignatura* asigUsu; if ((asigUsu = dynamic_cast<Asignatura*> (col3)) != NULL) { if(asig->getCodigo() == asigUsu->getCodigo()) { Integer* cod = new Integer(asig->getCodigo()); asignaturasNuevas->add(cod, asigUsu); found = true; } } else { throw "Criterio1: el parametro no es del tipo Asignatura"; } it3->next(); } delete it3; } else { throw "Criterio1: el parametro no es del tipo Aprobacion"; } it2->next(); } delete it2; } } else { throw "Criterio1: el parametro no es del tipo Estudiante"; } it->next(); } delete it; //if(!found) //asignaturas = new OrderedDictionary(); return asignaturasNuevas; }