BOOL CDomainContainer::GetDomains( CSPStringArray & astr ) { astr.SetSize( GetSize() ); for( int i=0; i<GetSize(); i++ ) { CDomain & domain = ElementAt(i); CSPString string = domain.m_strName; astr.SetAt( i, string ); } return TRUE; }
INT_PTR CHotKeys::Find(CHotKey* pHotKey) { INT_PTR count = GetSize(); for(int i=0; i < count; i++) { if(pHotKey == ElementAt(i)) { return i; } } return -1; }
void nsSVGTransformList::ReleaseTransforms() { PRInt32 count = mTransforms.Count(); for (PRInt32 i = 0; i < count; ++i) { nsIDOMSVGTransform* transform = ElementAt(i); nsCOMPtr<nsISVGValue> val = do_QueryInterface(transform); val->RemoveObserver(this); NS_RELEASE(transform); } mTransforms.Clear(); }
void CKData::AutoSetKType( ) { if( GetSize() >= 4 ) { long elapse1 = ElementAt(1).m_time - ElementAt(0).m_time; long elapse2 = ElementAt(2).m_time - ElementAt(1).m_time; long elapse3 = ElementAt(3).m_time - ElementAt(2).m_time; long elapse = min(elapse1,elapse2); elapse = min(elapse,elapse3); if( elapse < 600 ) m_nKType = ktypeMin5; else if( elapse < 1200 ) m_nKType = ktypeMin15; else if( elapse < 2400 ) m_nKType = ktypeMin30; else if( elapse < 7200 ) m_nKType = ktypeMin60; else if( elapse < 172800 ) m_nKType = ktypeDay; else if( elapse < 864000 ) m_nKType = ktypeWeek; else if( elapse < 4320000 ) m_nKType = ktypeWeek; } }
TextCompositionArray::index_type TextCompositionArray::IndexOf(const NativeIMEContext& aNativeIMEContext) { if (!aNativeIMEContext.IsValid()) { return NoIndex; } for (index_type i = Length(); i > 0; --i) { if (ElementAt(i - 1)->GetNativeIMEContext() == aNativeIMEContext) { return i - 1; } } return NoIndex; }
CHotKeys::~CHotKeys() { CHotKey* pHotKey; INT_PTR count = GetSize(); for(int i=0; i < count; i++) { pHotKey = ElementAt(i); if(pHotKey) { delete pHotKey; } } }
CStockInfo & CStockContainer::GetStockInfoByID( int nID ) { CSPMutex::Scoped l(m_mutex); if( ID_STOCKCNTN_AVERAGE == nID ) return m_infoAverage; if( ID_STOCKCNTN_WEIGHTAVERAGE == nID ) return m_infoWeightAverage; if( nID >= 0 && nID < GetSize() ) return ElementAt( nID ); SP_ASSERT( FALSE ); return m_infoNull; }
void nsSVGPathSegList::RemoveElementAt(PRInt32 index) { WillModify(); nsIDOMSVGPathSeg* seg = ElementAt(index); NS_ASSERTION(seg, "null pathsegment"); nsCOMPtr<nsISVGValue> val = do_QueryInterface(seg); if (val) val->RemoveObserver(this); mSegments.RemoveElementAt(index); NS_RELEASE(seg); DidModify(); }
// "BigInt" comes from the WebCrypto spec // ("unsigned long" isn't very "big", of course) // Likewise, the spec calls for big-endian ints bool CryptoBuffer::GetBigIntValue(unsigned long& aRetVal) { if (Length() > sizeof(aRetVal)) { return false; } aRetVal = 0; for (size_t i=0; i < Length(); ++i) { aRetVal = (aRetVal << 8) + ElementAt(i); } return true; }
int CDomainContainer::AddDomain( CDomain & newdomain ) { if( 0 == newdomain.m_strName.GetLength() ) return -1; for( int i=0; i<GetSize(); i++ ) { CDomain & domain = ElementAt(i); if( 0 == newdomain.m_strName.CompareNoCase( domain.m_strName ) ) return -1; } return Add( newdomain ); }
BOOL CKData::GetRatioVolume( double * pValue, DWORD dateCur, int nDays ) { SP_ASSERT( pValue && nDays > 0 ); // Find date Current to calculate from int nIndex = GetIndexByDate( dateCur ); if( -1 == nIndex ) return FALSE; // data not enough if( nDays > nIndex ) return FALSE; // 检查是否是相邻成交日 if( !IsAdjacentDays( nIndex, nDays ) ) return FALSE; // begin calculate double dAll = 0; int nCount = 0; for( int i=nIndex-1; i>=0; i-- ) { dAll += ElementAt(i).m_fVolume; nCount ++; if( nCount >= nDays ) break; } // data not enough if( nCount != nDays || nCount <= 0 ) return FALSE; if( fabs(dAll) < 1 ) return FALSE; if( pValue ) *pValue = (ElementAt(nIndex).m_fVolume / dAll ) * nCount; return TRUE; }
void nsSVGLengthList::ReleaseLengths() { WillModify(); PRInt32 count = mLengths.Count(); for (PRInt32 i = 0; i < count; ++i) { nsISVGLength* length = ElementAt(i); length->SetContext(nsnull, 0); NS_REMOVE_SVGVALUE_OBSERVER(length); NS_RELEASE(length); } mLengths.Clear(); DidModify(); }
/* nsIDOMSVGLengthList removeItem (in unsigned long index); */ NS_IMETHODIMP nsSVGLengthList::RemoveItem(PRUint32 index, nsIDOMSVGLength **_retval) { if (index >= static_cast<PRUint32>(mLengths.Count())) { *_retval = nsnull; return NS_ERROR_DOM_INDEX_SIZE_ERR; } *_retval = ElementAt(index); NS_ADDREF(*_retval); WillModify(); RemoveElementAt(index); DidModify(); return NS_OK; }
/* nsIDOMSVGPathSeg removeItem (in unsigned long index); */ NS_IMETHODIMP nsSVGPathSegList::RemoveItem(PRUint32 index, nsIDOMSVGPathSeg **_retval) { if (index >= NS_STATIC_CAST(PRUint32, mSegments.Count())) { *_retval = nsnull; return NS_ERROR_DOM_INDEX_SIZE_ERR; } *_retval = ElementAt(index); NS_ADDREF(*_retval); WillModify(); RemoveElementAt(index); DidModify(); return NS_OK; }
BOOL CKData::GetDiffPercent( double * pValue, DWORD dateCur, int nDays ) { SP_ASSERT( pValue && nDays > 0 ); // Find date Current to calculate from int nIndex = GetIndexByDate( dateCur ); if( -1 == nIndex ) return FALSE; // data not enough if( nDays > nIndex ) return FALSE; // 检查是否是相邻成交日 if( !IsAdjacentDays( nIndex, nDays ) ) return FALSE; if( ElementAt(nIndex-nDays).m_fAmount < 1e-4 ) return FALSE; if( pValue ) *pValue = (100. * ElementAt(nIndex).m_fClose) / ElementAt(nIndex-nDays).m_fClose - 100; return TRUE; }
void UI_Controller::Update(World *wrld) { // Select item if (MouseListener::mouse_pressed & 1 || MouseListener::mouse_pressed & 2) { int trans_x = mouse_x * ((wrld -> VIEWPORT_WIDTH / wrld -> VIEWPORT_ZOOM) / SCREEN_W); int trans_y = mouse_y * ((wrld -> VIEWPORT_HEIGHT / wrld -> VIEWPORT_ZOOM) / SCREEN_H); // Element at position UI_Element *elem = ElementAt(trans_x, trans_y); // Check if move if (elem != nullptr) { // Cast to slot UI_Slot *slt = dynamic_cast<UI_Slot*>(elem); // Ensure that it is slot if (slt != nullptr) { if (MouseListener::mouse_pressed & 1) { if (!(mouse_item -> GetItem()) && slt -> GetStack() -> GetItem()) { mouse_item -> SetItem(slt -> GetStack() -> GetItem(), slt -> GetStack() -> GetQuantity()); slt -> GetStack() -> Clear(); } else if(mouse_item -> GetItem() && !(slt -> GetStack() -> GetItem())) { slt -> GetStack() -> SetItem(mouse_item -> GetItem(), mouse_item -> GetQuantity()); mouse_item -> Clear(); } else if(mouse_item -> GetItem() && slt -> GetStack() -> GetItem() -> getID() == mouse_item -> GetItem() -> getID()) { slt -> GetStack() -> Add(mouse_item -> GetQuantity()); mouse_item -> Clear(); } } else if (MouseListener::mouse_pressed & 2) { if (!(mouse_item -> GetItem()) && slt -> GetStack() -> GetItem()) { int mouse_qty = ceil((float)slt -> GetStack() -> GetQuantity() / 2.0f); mouse_item -> SetItem(slt -> GetStack() -> GetItem(), mouse_qty); slt -> GetStack() -> Remove(mouse_qty); } else if(mouse_item -> GetItem() && !(slt -> GetStack() -> GetItem())) { slt -> GetStack() -> SetItem(mouse_item -> GetItem(), 1); mouse_item -> Remove(1); } else if(mouse_item -> GetItem() && slt -> GetStack() -> GetItem() -> getID() == mouse_item -> GetItem() -> getID()) { slt -> GetStack() -> Add(1); mouse_item -> Remove(1); } } } } } }
BOOL CDomain::RemoveStock( LPCTSTR lpszStockCode ) { if( NULL == lpszStockCode || strlen(lpszStockCode) <= 0 ) return FALSE; for( int k=0; k<GetSize(); k++ ) { if( 0 == ElementAt(k).CompareNoCase(lpszStockCode) ) { RemoveAt(k); return TRUE; } } return FALSE; }
BOOL CDomain::AddStock( LPCTSTR lpszStockCode ) { if( NULL == lpszStockCode || strlen(lpszStockCode) <= 0 ) return FALSE; for( int k=0; k<GetSize(); k++ ) { int nCmp = ElementAt(k).CompareNoCase(lpszStockCode); if( 0 == nCmp ) return FALSE; } Add( lpszStockCode ); return TRUE; }
void nsSVGPathSegList::ReleaseSegments() { WillModify(); PRInt32 count = mSegments.Count(); for (PRInt32 i = 0; i < count; ++i) { nsIDOMSVGPathSeg* seg = ElementAt(i); nsCOMPtr<nsISVGValue> val = do_QueryInterface(seg); if (val) val->RemoveObserver(this); NS_RELEASE(seg); } mSegments.Clear(); DidModify(); }
t4_i32 c4_Allocator::Allocate(t4_i32 len_) { // zero arg is ok, it simply returns first allocatable position for (int i = 2; i < GetSize(); i += 2) if (GetAt(i + 1) >= GetAt(i) + len_) { t4_i32 pos = GetAt(i); if ((t4_i32)GetAt(i + 1) > pos + len_) ElementAt(i) += len_; else RemoveAt(i, 2); return pos; } d4_assert(0); return 0; // not reached }
int CKData::FullFillKData( CKData & kdataMain, BOOL bFillToEnd ) { SP_ASSERT( GetKType() == kdataMain.GetKType() ); if( GetKType() != kdataMain.GetKType() ) return 0; if( GetSize() == 0 || kdataMain.GetSize() == 0 ) return 0; DWORD dateBegin = ElementAt(0).m_date; DWORD dateMainEnd5 = (kdataMain.GetSize() >= 5 ? kdataMain.ElementAt(kdataMain.GetSize()-5).m_date : 0); DWORD dateEnd5 = (GetSize() >= 5 ? ElementAt(GetSize()-5).m_date : 0); int iMain = 0, iSelf = 0; for( iMain=0; iMain<kdataMain.GetSize(); iMain ++ ) { if( dateBegin == kdataMain.ElementAt(iMain).m_date ) break; } SetSize( GetSize(), kdataMain.GetSize()-iMain-GetSize() > 0 ? kdataMain.GetSize()-iMain-GetSize() : -1 ); int nCount = 0; for( ; iMain <= kdataMain.GetSize() && iSelf <= GetSize(); iMain++, iSelf++ ) { if( !bFillToEnd && iSelf == GetSize() && ElementAt(iSelf-1).m_date < dateMainEnd5 ) break; if( !bFillToEnd && iMain == kdataMain.GetSize() && kdataMain.ElementAt(iMain-1).m_date < dateEnd5 ) break; while( iMain > 0 && iMain <= kdataMain.GetSize() && iSelf < GetSize() && ( iMain == kdataMain.GetSize() || kdataMain.ElementAt(iMain).m_date > ElementAt(iSelf).m_date ) ) { // KDATA kd; // memset( &kd, 0, sizeof(kd) ); // kd.m_date = ElementAt(iSelf).m_date; // kd.open = kd.high = kd.low = kd.close = kdataMain.ElementAt(iMain-1).close; // kdataMain.InsertAt( iMain, kd ); // iMain ++; iSelf ++; // nCount ++; } while( iMain < kdataMain.GetSize() && iSelf <= GetSize() && iSelf > 0 && ( iSelf == GetSize() || kdataMain.ElementAt(iMain).m_date < ElementAt(iSelf).m_date ) ) { KDATA kd; memset( &kd, 0, sizeof(kd) ); kd.m_date = kdataMain.ElementAt(iMain).m_date; kd.m_fOpen = kd.m_fHigh = kd.m_fLow = kd.m_fClose = ElementAt(iSelf-1).m_fClose; InsertAt( iSelf, kd ); iMain ++; iSelf ++; nCount ++; } } return nCount; }
BOOL CDomainContainer::GetDomainStocks( LPCTSTR lpszDomain, CSPStringArray &astr ) { if( NULL == lpszDomain || strlen(lpszDomain) < 0 ) return FALSE; for( int i=0; i<GetSize(); i++ ) { CDomain & domain = ElementAt(i); if( 0 == domain.m_strName.CompareNoCase( lpszDomain ) ) { astr.Copy( domain ); return TRUE; } } return FALSE; }
HTMLOptionElement* HTMLOptionsCollection::GetNamedItem(const nsAString& aName) const { uint32_t count = mElements.Length(); for (uint32_t i = 0; i < count; i++) { HTMLOptionElement* content = mElements.ElementAt(i); if (content && (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName, eCaseMatters) || content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName, eCaseMatters))) { return content; } } return nullptr; }
void CStockContainer::OnDataChanged( ) { CSPMutex::Scoped l(m_mutex); DWORD dateLatest = m_dwDate; if( -1 == dateLatest ) AfxGetStockContainer().GetLatestTechDate( &dateLatest ); for( int i=0; i<GetSize(); i++ ) { CStockInfo & info = ElementAt(i); info.StatBaseIndex( dateLatest ); info.StatTechIndex( dateLatest ); } SetAverage( ); }
BOOL CDomainContainer::RemoveDomainStockAll( LPCTSTR lpszDomainName ) { if( NULL == lpszDomainName || strlen(lpszDomainName) < 0 ) return FALSE; for( int i=0; i<GetSize(); i++ ) { CDomain & domain = ElementAt(i); if( 0 == domain.m_strName.CompareNoCase( lpszDomainName ) ) { domain.RemoveAll(); return TRUE; } } return FALSE; }
BOOL CDomainContainer::AddDomainStock( LPCTSTR lpszDomainName, LPCTSTR lpszStockCode ) { if( NULL == lpszDomainName || strlen(lpszDomainName) < 0 || NULL == lpszStockCode || strlen(lpszStockCode) < 0 ) return FALSE; for( int i=0; i<GetSize(); i++ ) { CDomain & domain = ElementAt(i); if( 0 == domain.m_strName.CompareNoCase( lpszDomainName ) ) { return domain.AddStock( lpszStockCode ); } } return FALSE; }
BOOL CKData::GetScope( double * pValue, DWORD dateCur, int nDays ) { SP_ASSERT( pValue && nDays > 0 ); // Find date Current to calculate from int nIndex = GetIndexByDate( dateCur ); if( -1 == nIndex ) return FALSE; // data not enough if( nDays > nIndex ) return FALSE; // 检查是否是相邻成交日 if( !IsAdjacentDays( nIndex, nDays ) ) return FALSE; double dMax = 0, dMin = 0; int nCount = 0; for( int k=nIndex; k>=0; k-- ) { if( nIndex == k ) { dMin = ElementAt(k).m_fLow; dMax = ElementAt(k).m_fHigh; } if( dMin > ElementAt(k).m_fLow ) dMin = ElementAt(k).m_fLow; if( dMax < ElementAt(k).m_fHigh ) dMax = ElementAt(k).m_fHigh; nCount ++; if( nCount == nDays ) break; } // data not enough if( nCount != nDays || nCount <= 0 ) return FALSE; if( ElementAt(nIndex-nDays).m_fClose <= 0 ) return FALSE; if( pValue ) *pValue = ( 100. * (dMax-dMin) ) / ElementAt(nIndex-nDays).m_fClose ; return TRUE; }
int COutline::InsertOutlineSort( OUTLINE newElement ) { for( int i=0; i<GetSize(); i++ ) { OUTLINE & temp = ElementAt(i); if( temp.m_time == newElement.m_time ) { SetAt(i,newElement); return i; } if( temp.m_time > newElement.m_time ) { InsertAt(i,newElement); return i; } } return Add( newElement ); }
BOOL CDomainContainer::AddDomainStock( LPCTSTR lpszDomainName, CSPStringArray & astr ) { if( NULL == lpszDomainName || strlen(lpszDomainName) < 0 ) return FALSE; for( int i=0; i<GetSize(); i++ ) { CDomain & domain = ElementAt(i); if( 0 == domain.m_strName.CompareNoCase( lpszDomainName ) ) { for( int j=0; j<astr.GetSize(); j++ ) domain.AddStock( astr.ElementAt(j) ); return TRUE; } } return FALSE; }
BOOL CStockContainer::SetMap( ) { CSPMutex::Scoped l(m_mutex); m_map.RemoveAll( ); if( GetSize() == 0 ) return TRUE; m_map.InitHashTable( GetSize() * 2 + 10 ); for( int i=0; i<GetSize(); i++ ) { CStockInfo &info = ElementAt(i); m_map.SetAt( info.GetStockCode(), (void *)i ); } return TRUE; }