Esempio n. 1
0
OGRErr OGRMultiPoint::exportToWkt( char ** ppszDstText,
                                   OGRwkbVariant eWkbVariant ) const

{
    int         nMaxString = getNumGeometries() * 22 + 128;
    int         nRetLen = 0;

/* -------------------------------------------------------------------- */
/*      Return MULTIPOINT EMPTY if we get no valid points.              */
/* -------------------------------------------------------------------- */
    if( IsEmpty() )
    {
        if( getCoordinateDimension() == 3 && eWkbVariant == wkbVariantIso )
            *ppszDstText = CPLStrdup("MULTIPOINT Z EMPTY");
        else
            *ppszDstText = CPLStrdup("MULTIPOINT EMPTY");
        return OGRERR_NONE;
    }

    *ppszDstText = (char *) VSIMalloc( nMaxString );
    if( *ppszDstText == NULL )
        return OGRERR_NOT_ENOUGH_MEMORY;

    if( getCoordinateDimension() == 3 && eWkbVariant == wkbVariantIso )
        sprintf( *ppszDstText, "%s Z (", getGeometryName() );
    else
        sprintf( *ppszDstText, "%s (", getGeometryName() );

    int bMustWriteComma = FALSE;
    for( int i = 0; i < getNumGeometries(); i++ )
    {
        OGRPoint        *poPoint = (OGRPoint *) getGeometryRef( i );

        if (poPoint->IsEmpty())
        {
            CPLDebug( "OGR", "OGRMultiPoint::exportToWkt() - skipping POINT EMPTY.");
            continue;
        }

        if( bMustWriteComma )
            strcat( *ppszDstText + nRetLen, "," );
        bMustWriteComma = TRUE;

        nRetLen += strlen(*ppszDstText + nRetLen);

        if( nMaxString < nRetLen + 100 )
        {
            nMaxString = nMaxString * 2;
            *ppszDstText = (char *) CPLRealloc(*ppszDstText,nMaxString);
        }

        if( eWkbVariant == wkbVariantIso )
        {
            strcat( *ppszDstText + nRetLen, "(" );
            nRetLen ++;
        }

        OGRMakeWktCoordinate( *ppszDstText + nRetLen,
                              poPoint->getX(), 
                              poPoint->getY(),
                              poPoint->getZ(),
                              poPoint->getCoordinateDimension() );

        if( eWkbVariant == wkbVariantIso )
        {
            strcat( *ppszDstText + nRetLen, ")" );
            nRetLen ++;
        }
    }

    strcat( *ppszDstText+nRetLen, ")" );

    return OGRERR_NONE;
}
Esempio n. 2
0
bool
TopographyFile::Update(const WindowProjection &map_projection)
{
  if (IsEmpty())
    return false;

  if (map_projection.GetMapScale() > scale_threshold)
    /* not visible, don't update cache now */
    return false;

  const GeoBounds screenRect =
    map_projection.GetScreenBounds();
  if (cache_bounds.inside(screenRect))
    /* the cache is still fresh */
    return false;

  cache_bounds = map_projection.GetScreenBounds().scale(fixed_two);

  rectObj deg_bounds = ConvertRect(cache_bounds);

  // Test which shapes are inside the given bounds and save the
  // status to file.status
  msShapefileWhichShapes(&file, dir, deg_bounds, 0);

  // If not a single shape is inside the bounds
  if (!file.status) {
    // ... clear the whole buffer
    ClearCache();
    return false;
  }

  // Iterate through the shapefile entries
  for (int i = 0; i < file.numshapes; i++) {
    if (!msGetBit(file.status, i)) {
      // If the shape is outside the bounds
      // delete the shape from the cache
      delete shapes[i].shape;
      shapes[i].shape = NULL;
    } else if (shapes[i].shape == NULL) {
      // If the shape is inside the bounds and if the
      // shape isn't cached yet -> cache the shape
      shapes[i].shape = new XShape(&file, i, label_field);
    }
  }

  ShapeList::NotNull not_null;
  XShapePointerArray::iterator end = shapes.end(), it = shapes.begin();
  it = std::find_if(it, end, not_null);
  if (it != shapes.end()) {
    ShapeList *current = &*it;
    first = current;

    while (true) {
      ++it;
      it = std::find_if(it, end, not_null);
      if (it == end) {
        current->next = NULL;
        break;
      }

      ShapeList *next = &*it;
      current->next = next;
      current = next;
    }
  } else
    first = NULL;

  return true;
}
bool MyProduceConsume::ConsumeComplete() {
    return IsEmpty() && ProduceComplete();
}
BOOLEAN
FxEventQueue::QueueToThreadWorker(
    VOID
    )
/*++

Routine Description:
    Generic worker function which encapsulates the logic of whether to enqueue
    onto a different thread if the thread has not already been queued to.

    NOTE: this function could have been virtual, or call a virtual worker function
          once we have determined that we need to queue to a thread.  But to save
          space on vtable storage (why have one unless you really need one?),
          we rearrange the code so that the derived class calls the worker function
          and this function indicates in its return value what the caller should
          do

Arguments:
    None

Return Value:
    TRUE if the caller should queue to a thread to do the work
    FALSE if the caller shoudl not queue to a thread b/c it has already been
          queued

  --*/
{
    KIRQL irql;
    BOOLEAN result;

    Lock(&irql);

    //
    // For one reason or another, we couldn't run the state machine on this
    // thread.  So queue a work item to do it.
    //
    if (IsEmpty()) {
        //
        // There is no work to do.  This means that the caller inserted the
        // event into the queue, dropped the lock, and then another thread came
        // in and processed the event.
        //
        // This check also helps in the rundown case when the queue is closing
        // and the following happens between 2 thread:
        // #1                       #2
        // insert event
        // drop lock
        //                          process event queue
        //                          queue goes to empty, so event is set
        // try to queue work item
        //
        result = FALSE;

        DoTraceLevelMessage(
            m_PkgPnp->GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
            "WDFDEVICE 0x%p !devobj 0x%p not queueing work item to process "
            "event queue", m_PkgPnp->GetDevice()->GetHandle(),
            m_PkgPnp->GetDevice()->GetDeviceObject());
    }
    else if ((m_QueueFlags & FxEventQueueFlagWorkItemQueued) == 0x00) {
        m_QueueFlags |= FxEventQueueFlagWorkItemQueued;
        result = TRUE;
    }
    else {
        //
        // Somebody is already in the process of enqueuing the work item.
        //
        result = FALSE;
    }

    Unlock(irql);

    return result;
}
Esempio n. 5
0
Prefix::Prefix( const struct PROJ_DB * pDB ) : SeqWrap()
{
//#define GetDBPrefix_PRINT_DEBUG_INFO

	int i = 0;
	int j = 0;
	int JMax = 1;
	bool Inter;
	SeqWrap * aSeqWrap = NULL;
	bool PrefixIsEmpty = true;

#ifdef GetDBPrefix_PRINT_DEBUG_INFO

	Sequence * aSeq = NULL;
	Sequence * tmpSeq = NULL;
	static int Cnt = 0;

	tmpSeq = new Sequence( pDB );
	printf( "  Original Prefix %dth Record ===> ", Cnt++ );
	(*tmpSeq).Print();
	delete tmpSeq;
#endif
	
	End = NULL;
	NumOfItemSets = 0;
	//Sup = 1;
	Sup = 0; 
	if( (*pDB).m_nSup > 0 )
	{
		// Find first none empty sequence.
		for( i=0; i<(*pDB).m_nSup; i++ )
		{
			for( j=0; j < (*pDB).m_pProjSeq[i].m_nProjCount; j++ )
			{
				aSeqWrap = new SeqWrap( GetStartPtr( pDB, i, j ) );

				if( !(*aSeqWrap).IsEmpty() )
				{
					Start = (*aSeqWrap).GetFirst();
					End = GetEndPtr( Start ) - 1;
					//TrimPrefix( Start ); //Trim it with itself.
					PrefixIsEmpty = false;
					#ifdef GetDBPrefix_PRINT_DEBUG_INFO
						aSeq = new Sequence( Start, End-Start, 0, true );
						printf( "  First Prefix %dth Record ===> ", i+1 );
						if( aSeq ) (*aSeq).Print();
						printf( "    Real First Start=%d End=%d Size=%d ===> ", Start, End, End-Start );
						Print();
					#endif

					delete aSeqWrap;
					break;
				}
				delete aSeqWrap;
			}
			if( Start != End )
				break;
		}
	}

	if( Start != End )
	{
		JMax = 1;
		if( *(Start) == -1 )
			Inter = true;
		else
			Inter = false;

		//for( i++; i<(*pDB).m_nSup; i++ ) // For every seq in DB
		for( i; i<(*pDB).m_nSup; i++ ) // For every seq in DB
		{
			if( !Inter )
				JMax = (*pDB).m_pProjSeq[i].m_nProjCount;

			//JMax = 1;
			for( j=0; j < JMax; j++ )
			{
				aSeqWrap = new SeqWrap( GetStartPtr( pDB, i, j ) );

#ifdef GetDBPrefix_PRINT_DEBUG_INFO
				tmpSeq = new Sequence( (*aSeqWrap).GetFirst(), true );
				printf( "  %dth Record ===> ", i+1 );
				(*tmpSeq).Print();
				delete tmpSeq;
#endif


				if( !(*aSeqWrap).IsEmpty() )
				{
					TrimPrefix( (*aSeqWrap).GetFirst() );
					Sup++;
#ifdef GetDBPrefix_PRINT_DEBUG_INFO
					if( Start != End )
					{
						aSeq = new Sequence( Start, End-Start, 0, true );
						printf( "     ++++++++++++++++ Remaining prefix is  " );
						(*aSeq).Print();
						printf( "        +++++Real Start=%d End=%d Size=%d prefix is ", Start, End, End-Start );
						Print();
					}
#endif
				}
				delete aSeqWrap;

				PrefixIsEmpty = IsEmpty();
				if( PrefixIsEmpty )
					break;
			}				
			if( PrefixIsEmpty )
				break;
		}
	}

	//if( Start == End )	
	if( PrefixIsEmpty )	
	{
		Start = NULL;
		End = NULL;
		NumOfItemSets = 0;
		Sup = 0;
	} else {
		CalcNumOfItemSets();
	}

}
Esempio n. 6
0
void CVkWallPostForm::On_edtValue_Change(CCtrlEdit*)
{
	m_btnShare.Enable(!IsEmpty(ptrT(m_edtMsg.GetText())) || !IsEmpty(ptrT(m_edtUrl.GetText())));
}
Esempio n. 7
0
void PrintResult( LineData * dest_lines, int comm_size, size_t linesize )
{
    LineData *	pline;
    char	nodelist[MAXNODELIST];
    char *	pnext;
    char *	ptoken;
    int	numc;
    int	i;

    /* Look for lines that survived the merge and print them*/
    for( pline = dest_lines, i = 0; i < comm_size;
            pline += linesize, i++ ) {
        if( !IsEmpty( pline+SET ) ) {
            /* Create a compact list of nodes for this string */
            int j, start = INVALID, end, firsttime = 1;
            int hasnodepattern = 0;
            pnext = nodelist;

            for( j = 0; j < comm_size; j++ ) {
                if( CheckSet( pline+SET, j ) ) {
                    STARTRANGE(start,end,j);
                } else if ( start != INVALID ) {
                    ENDRANGE(start,end,firsttime);
                }
            }
            if( start != INVALID ) {
                ENDRANGE(start,end,firsttime);
            }

            /* Reconvert the node list substitution and the
             * literal percent patterns.
             */
            for( ptoken = strchr( pline+TEXT, PERCENTSUB );
                    ptoken != NULL;
                    ptoken = strchr( ptoken + 2, PERCENTSUB ) ) {

                if( ptoken[1] == NODESUB ) {
                    /* Only allow one copy of the pattern;
                     * otherwise, make it a percent.
                     * (because we can't pass variable
                     * number of copies of the nodelist).
                     */
                    *ptoken = '%';
                    if( !hasnodepattern ) ptoken[1] = 's';
                    else ptoken[1] = '%';
                    hasnodepattern = 1;
                } else if( ptoken[1] == PERCENTSUB ) {
                    *ptoken = ptoken[1] = '%';
                }
            }

            if( !hasnodepattern ) {
                /* Use separate printfs so the output line
                 * will be processed by print once in either
                 * case.
                 */
                printf( "%s ", nodelist );
                printf( pline+TEXT );
            } else {
                printf( pline+TEXT, nodelist );
            }
        }
    }
}
Esempio n. 8
0
void Pop( Stack S ) {
    if (IsEmpty(S))
        Error("Stack is empty!");
    else
        --S->TopOfStack;
}
nsresult
nsXBLProtoImplField::InstallField(nsIScriptContext* aContext,
                                  JSObject* aBoundNode,
                                  nsIURI* aBindingDocURI,
                                  bool* aDidInstall) const
{
  NS_PRECONDITION(aBoundNode,
                  "uh-oh, bound node should NOT be null or bad things will "
                  "happen");

  *aDidInstall = false;

  // Empty fields are treated as not actually present.
  if (IsEmpty()) {
    return NS_OK;
  }

  nsAutoMicroTask mt;

  // EvaluateString and JS_DefineUCProperty can both trigger GC, so
  // protect |result| here.
  nsresult rv;

  nsAutoCString uriSpec;
  aBindingDocURI->GetSpec(uriSpec);
  
  JSContext* cx = aContext->GetNativeContext();
  NS_ASSERTION(!::JS_IsExceptionPending(cx),
               "Shouldn't get here when an exception is pending!");
  
  // compile the literal string
  nsCOMPtr<nsIScriptContext> context = aContext;

  JSAutoRequest ar(cx);
  jsval result = JSVAL_NULL;

  JS::CompileOptions options(cx);
  options.setFileAndLine(uriSpec.get(), mLineNumber)
         .setVersion(JSVERSION_LATEST)
         .setUserBit(true); // Flag us as XBL
  rv = context->EvaluateString(nsDependentString(mFieldText,
                                                 mFieldTextLength),
                               *aBoundNode, options,
                               /* aCoerceToString = */ false,
                               &result);
  if (NS_FAILED(rv)) {
    return rv;
  }


  // Define the evaluated result as a JS property
  nsDependentString name(mName);
  if (!::JS_DefineUCProperty(cx, aBoundNode,
                             reinterpret_cast<const jschar*>(mName), 
                             name.Length(), result, nullptr, nullptr,
                             mJSAttributes)) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  *aDidInstall = true;
  return NS_OK;
}
Esempio n. 10
0
SqlSet& SqlSet::Cat(const SqlVal& val) {
	if(!IsEmpty()) text.Cat(", ");
	text.Cat(~val);
	priority = SET;
	return *this;
}
Esempio n. 11
0
result_t JSHandler::invoke(object_base *v, obj_ptr<Handler_base> &retVal,
                           AsyncEvent *ac)
{
    if (ac)
        return CHECK_ERROR(CALL_E_NOASYNC);

    v8::Local<v8::Object> o = v->wrap();
    Isolate* isolate = holder();

    obj_ptr<Message_base> msg = Message_base::getInstance(v);
    v8::Local<v8::Value> a = v8::Local<v8::Value>::New(isolate->m_isolate, o);
    v8::Local<v8::Value> hdlr = GetPrivate("handler");

    while (true)
    {
        v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(hdlr);
        obj_ptr<List_base> params;
        std::vector<v8::Local<v8::Value> > argv;
        v8::Local<v8::Value> *pargv;
        int32_t len = 0, i;

        if (msg != NULL)
        {
            msg->get_params(params);
            params->get_length(len);
        }

        if (len > 0)
        {
            argv.resize(len + 1);
            argv[0] = a;

            for (i = 0; i < len; i++)
            {
                Variant v;
                params->_indexed_getter(i, v);
                argv[i + 1] = v;
            }

            pargv = argv.data();
        }
        else
            pargv = &a;

        {
            TryCatch try_catch;
            hdlr = func->Call(v8::Undefined(isolate->m_isolate), len + 1, pargv);
            if (try_catch.HasCaught())
            {
                v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
                        isolate->m_isolate, 1, v8::StackTrace::kScriptId);
                if (stackTrace->GetFrameCount() > 0)
                {
                    try_catch.ReThrow();
                    return CALL_E_JAVASCRIPT;
                }
                else
                    return CHECK_ERROR(Runtime::setError(GetException(try_catch, 0)));
            }
        }

        if (IsEmpty (hdlr))
            return CALL_RETURN_NULL;

        if (!hdlr->IsFunction())
        {
            if (hdlr->IsObject())
                return JSHandler::New(hdlr, retVal);

            msg->set_result(hdlr);
            return CALL_RETURN_NULL;
        }
    }

    return 0;
}
Esempio n. 12
0
String SqlSet::operator()(int at) const {
	if(IsEmpty()) return "null";
	return at > priority ? '(' + text + ')' : text;
}
Esempio n. 13
0
String SqlSet::operator()() const {
	if(IsEmpty()) return "null";
	return '(' + text + ')';
}
Esempio n. 14
0
String SqlSet::operator~() const {
	if(IsEmpty()) return "null";
	return text;
}
Esempio n. 15
0
void Chunk::RenderDebug()
{
	float l_length = (Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE) - 0.05f;
	float l_height = (Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE) - 0.05f;
	float l_width = (Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE) - 0.05f;

	m_pRenderer->SetRenderMode(RM_WIREFRAME);
	m_pRenderer->SetCullMode(CM_NOCULL);
	m_pRenderer->SetLineWidth(1.0f);

	m_pRenderer->PushMatrix();
		m_pRenderer->TranslateWorldMatrix(m_position.x, m_position.y, m_position.z);
		m_pRenderer->TranslateWorldMatrix(Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE);
		m_pRenderer->TranslateWorldMatrix(-Chunk::BLOCK_RENDER_SIZE, -Chunk::BLOCK_RENDER_SIZE, -Chunk::BLOCK_RENDER_SIZE);

		m_pRenderer->ImmediateColourAlpha(1.0f, 1.0f, 0.0f, 1.0f);
		if (IsEmpty())
		{
			m_pRenderer->ImmediateColourAlpha(1.0f, 0.0f, 0.0f, 1.0f);
		}
		else if (IsSurrounded())
		{
			m_pRenderer->ImmediateColourAlpha(0.0f, 1.0f, 1.0f, 1.0f);
		}

		m_pRenderer->EnableImmediateMode(IM_QUADS);
			m_pRenderer->ImmediateNormal(0.0f, 0.0f, -1.0f);
			m_pRenderer->ImmediateVertex(l_length, -l_height, -l_width);
			m_pRenderer->ImmediateVertex(-l_length, -l_height, -l_width);
			m_pRenderer->ImmediateVertex(-l_length, l_height, -l_width);
			m_pRenderer->ImmediateVertex(l_length, l_height, -l_width);

			m_pRenderer->ImmediateNormal(0.0f, 0.0f, 1.0f);
			m_pRenderer->ImmediateVertex(-l_length, -l_height, l_width);
			m_pRenderer->ImmediateVertex(l_length, -l_height, l_width);
			m_pRenderer->ImmediateVertex(l_length, l_height, l_width);
			m_pRenderer->ImmediateVertex(-l_length, l_height, l_width);

			m_pRenderer->ImmediateNormal(1.0f, 0.0f, 0.0f);
			m_pRenderer->ImmediateVertex(l_length, -l_height, l_width);
			m_pRenderer->ImmediateVertex(l_length, -l_height, -l_width);
			m_pRenderer->ImmediateVertex(l_length, l_height, -l_width);
			m_pRenderer->ImmediateVertex(l_length, l_height, l_width);

			m_pRenderer->ImmediateNormal(-1.0f, 0.0f, 0.0f);
			m_pRenderer->ImmediateVertex(-l_length, -l_height, -l_width);
			m_pRenderer->ImmediateVertex(-l_length, -l_height, l_width);
			m_pRenderer->ImmediateVertex(-l_length, l_height, l_width);
			m_pRenderer->ImmediateVertex(-l_length, l_height, -l_width);

			m_pRenderer->ImmediateNormal(0.0f, -1.0f, 0.0f);
			m_pRenderer->ImmediateVertex(-l_length, -l_height, -l_width);
			m_pRenderer->ImmediateVertex(l_length, -l_height, -l_width);
			m_pRenderer->ImmediateVertex(l_length, -l_height, l_width);
			m_pRenderer->ImmediateVertex(-l_length, -l_height, l_width);

			m_pRenderer->ImmediateNormal(0.0f, 1.0f, 0.0f);
			m_pRenderer->ImmediateVertex(l_length, l_height, -l_width);
			m_pRenderer->ImmediateVertex(-l_length, l_height, -l_width);
			m_pRenderer->ImmediateVertex(-l_length, l_height, l_width);
			m_pRenderer->ImmediateVertex(l_length, l_height, l_width);
		m_pRenderer->DisableImmediateMode();
	m_pRenderer->PopMatrix();

	m_pRenderer->SetCullMode(CM_BACK);
}
Esempio n. 16
0
void NewBuildTab::OnClearUI(wxUpdateUIEvent& e) { e.Enable(!m_buildInProgress && !IsEmpty()); }
Esempio n. 17
0
//Inserts a character into the buffer.
void CConsole::InsertChar(const int szChar, const wchar_t cooked )
{
	static int iHistoryPos = -1;

	if (!m_bVisible) return;

	switch (szChar){
		case SDLK_RETURN:
			iHistoryPos = -1;
			m_iMsgHistPos = 1;
			ProcessBuffer(m_szBuffer);
			FlushBuffer();
			return;

		case SDLK_TAB:
			// Auto Complete
			return;

		case SDLK_BACKSPACE:
			if (IsEmpty() || IsBOB()) return;

			if (m_iBufferPos == m_iBufferLength)
				m_szBuffer[m_iBufferPos - 1] = '\0';
			else{
				for(int j=m_iBufferPos-1; j<m_iBufferLength-1; j++)
					m_szBuffer[j] = m_szBuffer[j+1]; // move chars to left
				m_szBuffer[m_iBufferLength-1] = '\0';
			}

			m_iBufferPos--;
			m_iBufferLength--;
			return;

		case SDLK_DELETE:
			if (IsEmpty() || IsEOB()) return;

			if (m_iBufferPos == m_iBufferLength-1)
			{
				m_szBuffer[m_iBufferPos] = '\0';
				m_iBufferLength--;
			}
			else
			{
				if (g_keys[SDLK_RCTRL] || g_keys[SDLK_LCTRL])
				{
					// Make Ctrl-Delete delete up to end of line
					m_szBuffer[m_iBufferPos] = '\0';
					m_iBufferLength = m_iBufferPos;
				}
				else 
				{
					// Delete just one char and move the others left
					for(int j=m_iBufferPos; j<m_iBufferLength-1; j++)
						m_szBuffer[j] = m_szBuffer[j+1];
					m_szBuffer[m_iBufferLength-1] = '\0';
					m_iBufferLength--;
				}
			}

			return;

		case SDLK_HOME:
			if (g_keys[SDLK_RCTRL] || g_keys[SDLK_LCTRL])
			{
				CScopeLock lock(m_Mutex); // needed for safe access to m_deqMsgHistory

				int linesShown = (int)m_fHeight/m_iFontHeight - 4;
				m_iMsgHistPos = clamp((int)m_deqMsgHistory.size() - linesShown, 1, (int)m_deqMsgHistory.size());
			}
			else
			{
				m_iBufferPos = 0;
			}
			return;

		case SDLK_END:
			if (g_keys[SDLK_RCTRL] || g_keys[SDLK_LCTRL])
			{
				m_iMsgHistPos = 1;
			}
			else
			{
				m_iBufferPos = m_iBufferLength;
			}
			return;

		case SDLK_LEFT:
			if (m_iBufferPos) m_iBufferPos--;
			return;

		case SDLK_RIGHT:
			if (m_iBufferPos != m_iBufferLength) m_iBufferPos++;
			return;

		// BEGIN: Buffer History Lookup
		case SDLK_UP:
			if ( m_deqBufHistory.size() )
			{
				int oldHistoryPos = iHistoryPos;
				while( iHistoryPos != (int)m_deqBufHistory.size() - 1)
				{
					iHistoryPos++;
					std::wstring& histString = m_deqBufHistory.at(iHistoryPos);
					if((int)histString.length() >= m_iBufferPos)
					{
						bool bad = false;
						for(int i=0; i<m_iBufferPos; i++)
						{
							if(histString[i] != m_szBuffer[i])
							{
								bad = true; break;
							}
						}
						if(!bad)
						{
							SetBuffer(m_deqBufHistory.at(iHistoryPos).c_str());
							return;
						}
					}
				}
				// if we got here, failed to find a string with the right prefix;
				// revert to the old position in case the user types more stuff
				iHistoryPos = oldHistoryPos;
			}
			return;

		case SDLK_DOWN:
			if ( m_deqBufHistory.size() && iHistoryPos > 0 )
			{
				int oldHistoryPos = iHistoryPos;
				while( iHistoryPos != 0)
				{
					iHistoryPos--;
					std::wstring& histString = m_deqBufHistory.at(iHistoryPos);
					if((int)histString.length() >= m_iBufferPos)
					{
						bool bad = false;
						for(int i=0; i<m_iBufferPos; i++)
						{
							if(histString[i] != m_szBuffer[i])
							{
								bad = true; break;
							}
						}
						if(!bad)
						{
							SetBuffer(m_deqBufHistory.at(iHistoryPos).c_str());
							return;
						}
					}
				}
				// if we got here, failed to find a string with the right prefix;
				// revert to the old position in case the user types more stuff,
				// and also clear any complietion we might've added going up
				iHistoryPos = oldHistoryPos;
				m_szBuffer[m_iBufferPos] = 0;
				m_iBufferLength = m_iBufferPos;
			}
			return;
		// END: Buffer History Lookup

		// BEGIN: Message History Lookup
		case SDLK_PAGEUP:
		{
			CScopeLock lock(m_Mutex); // needed for safe access to m_deqMsgHistory

			if (m_iMsgHistPos != (int)m_deqMsgHistory.size()) m_iMsgHistPos++;
			return;
		}

		case SDLK_PAGEDOWN:
			if (m_iMsgHistPos != 1) m_iMsgHistPos--;
			return;
		// END: Message History Lookup

		default: //Insert a character
			if (IsFull()) return;
			if (cooked == 0) return;

			if (IsEOB()) //are we at the end of the buffer?
				m_szBuffer[m_iBufferPos] = cooked; //cat char onto end
			else{ //we need to insert
				int i;
				for(i=m_iBufferLength; i>m_iBufferPos; i--)
					m_szBuffer[i] = m_szBuffer[i-1]; // move chars to right
				m_szBuffer[i] = cooked;
			}

			m_iBufferPos++;
			m_iBufferLength++;

			return;
	}
}
Esempio n. 18
0
int checkEmpty(finsQueue Q) {
	return (IsEmpty(Q));
}
Esempio n. 19
0
void CVkCaptchaForm::On_edtValue_Change(CCtrlEdit*)
{
	m_btnOk.Enable(!IsEmpty(ptrA(m_edtValue.GetTextA())));
}
Esempio n. 20
0
BOOLEAN KBinaryTree::Delete(VOID* data, ULONG dwCompareParam)
{
  BOOLEAN     bRet = FALSE;
  KBinaryTreeNode* item;
  KBinaryTreeNode* startitem;
  KBinaryTreeNode* y;
  KBinaryTreeNode* z;
  KLocker locker(&m_KSynchroObject);


  if (!IsEmpty())
  {
    item = m_pRootTree->SearchByNode(data, m_pCompare, dwCompareParam);
    if (item != NULL)
    {
      // if we want to delete the root item, we have to do some extra
      // operation the preserve some pointers...
      if (item == m_pRootTree)
      {
        // the root is the only one node in the tree
        if (item->m_pLeft == NULL && item->m_pRight == NULL)
        {
          delete m_pRootTree;
          m_pRootTree = NULL;
          return TRUE;
        }
      }

      // start node for restructuration
      startitem = NULL;
      // node to delete has no children
      if (item->m_pLeft == NULL && item->m_pRight == NULL)
      {
        if (item->IsLeftSibling())
          item->m_pParent->m_pLeft = NULL;
        else
          item->m_pParent->m_pRight = NULL;
        startitem = item->m_pParent;
        delete item;
        item = NULL;
      }
      // node to delete has only right son
      if (item != NULL && item->m_pLeft == NULL && item->m_pRight != NULL)
      {
        item->m_pData = item->m_pRight->m_pData;
        item->m_pRight->m_pData = NULL;

        delete item->m_pRight;

        item->m_pRight = NULL;
        startitem = item;
      }
      // node to delete has only left son
      if (item != NULL && item->m_pLeft != NULL && item->m_pRight == NULL)
      {
        item->m_pData = item->m_pLeft->m_pData;
        item->m_pLeft->m_pData = NULL;

        delete item->m_pLeft;

        item->m_pLeft = NULL;
        startitem = item;
      }
      // node to delete has both sons
      if (item != NULL && item->m_pLeft != NULL && item->m_pRight != NULL)
      {
        y = item->m_pLeft->GetLastNodeInOrder();
        z = y->m_pLeft;

        item->m_pData = y->m_pData;
        y->m_pData = NULL;
        /*
        if (y->IsLeftSibling())
            y->Parent->Left = z;
        else
            y->Parent->Right = z;
        */
        if (z != NULL)
        {
          y->m_pData = z->m_pData;
          z->m_pData = NULL;
          y->m_pLeft = NULL;
          delete z;
          startitem = y;
        }
        else
        {
          if (y->IsLeftSibling())
             y->m_pParent->m_pLeft = NULL;
          else
             y->m_pParent->m_pRight = NULL;
          startitem = y->m_pParent;
          delete y;
        }
      }

      if (startitem != NULL)
        startitem->RestructureDelete();

      m_pRootTree = m_pRootTree->GetRootByNode();
      
      bRet = TRUE;
    }
  }

  return bRet;
}
Esempio n. 21
0
void PrintReduceOp(	void *		invec,
                    void *		inoutvec,
                    int *		len,
                    MPI_Datatype *	datatype )
{
    LineData *	src_data =
        (LineData *)((char*)invec + 2 * sizeof(int));
    LineData *	dest_data =
        (LineData *)((char*)inoutvec + 2 * sizeof(int));
    LineData *	psrcline, * pdestline;
    int		i, j;
    int		count = ((int *)invec)[0];
    int		linesize = ((int *)invec)[1];

    datatype = datatype;
    len = len;

    /* Run through each (valid) entry in dest_data and compare it with
     * each valid entry in src_data.
     */

    for( pdestline = dest_data, i = 0; i < count;
            pdestline += linesize, i++ ) {

        /* An empty set indicates that the string is blank; skip it */
        if( IsEmpty( pdestline+SET ) ) continue;

        /* We have a valid string; compare it with each of the
         * strings in the incoming vector.
         */
        for( psrcline = src_data, j = 0; j < count;
                psrcline += linesize, j++ ) {

            /* Skip blank entries */
            if( IsEmpty( psrcline+SET ) ) continue;

            /* If they match, remove this string (because it
             * won't match any other entries), and mark the
             * nodes where it appeared.  Once we've found a
             * match to this dest string, there won't be any
             * more in the source array because it should
             * contain only one copy of each string, so we
             * can quit this inner loop after the first match.
             */
            if( strcmp( pdestline+TEXT, psrcline+TEXT ) == 0 ) {
                UnionSet( pdestline+SET, psrcline+SET );
                ClearSet( psrcline+SET );
                /* We want to put the result in the
                 * lowest-numbered position in the destination
                 * array so items will come out in the order
                 * of the lowest-numbered node in the set when
                 * we print the sets out.
                 */
                if( j < i ) {
                    /* Move to lower-numbered position */
                    LineData * lower
                        = dest_data + (j * linesize);
                    UnionSet( lower+SET, pdestline+SET );
                    ClearSet( pdestline+SET );
                    strcpy( lower+TEXT, pdestline+TEXT );
                }
                break;
            }
        }
    }

    /* All the matching strings should now be copied into the source.
     * Those remaining are unique, so we can copy them all into the
     * dest array.  Since each node sends only one string, there's no
     * danger of overwriting an entry in dest when we copy an entry
     * from source.
     */

    for( pdestline = dest_data, psrcline = src_data, i = 0; i < count;
            pdestline += linesize,
            psrcline += linesize, i++ ) {

        /* If we find a string whose entry hasn't been cleared,
         * copy it and its list of nodes.
         */
        if( !IsEmpty( psrcline+SET ) ) {
            UnionSet( pdestline+SET, psrcline+SET );
            strcpy( pdestline+TEXT, psrcline+TEXT );
        }
    }

}
Esempio n. 22
0
CaReplicationItemList::~CaReplicationItemList()
{
	while (!IsEmpty())
		delete RemoveHead();
}
Esempio n. 23
0
 ~CircularBuffer()
 {
     // For ThreadCommands, we must consume everything before shutdown.
     OVR_ASSERT(IsEmpty());
     OVR_FREE_ALIGNED(pBuffer);
 }
Esempio n. 24
0
 const char *PeekNext() const {
     return IsEmpty() ? NULL : args.front();
 }
Esempio n. 25
0
int main()
{
	/*kamus*/
	Queue Q;
	int n,n2,i;
	int t = 0; // waktu masukan
	int pret = 0; // waktu sebelum t. cek pret<=t
	int tclose; // waktu tutup
	int visitor = 0;
	float srvtime = 0; // total waktu pelayanan
	float que = 0; // total antrian*waktu
	char input[6];
	boolean close;
	/*algoritma*/
	printf("Ukuran Queue : ");
	scanf("%d",&n);
	CreateEmpty(&Q,n);
	close = false;
	do {
		printf("Masukkan perintah: ");
		scanf("%d%s",&t,input);
		if(t<pret) printf("Waktu yang dimasukkan tidak valid, seharusnya >= %d\n",pret);
		else {
			switch(input[0]) {
				case 'a' : 
							if(IsFull(Q)) printf("Queue penuh, tidak bisa menerima pengunjung baru\n");
							else {
								que+=NBElmt(Q)*(t-pret);
								Add(&Q,t);
								printf("Q = ");
								PrintQueue(Q);
							}
							break;
				case 'c' :
							close = true;
							tclose = t;
							if (IsEmpty(Q)) 
								printf("Bank tutup, tidak ada pengunjung tersisa\n");
							else printf("Bank tutup, masih ada %d pengunjung tersisa\n",NBElmt(Q));
							break;
				case 'd' :
							if(IsEmpty(Q))
								printf("Queue kosong, tidak ada pengunjung yang akan dilayani\n");
							else {
								visitor++;
								Del(&Q,&n);
								if(!close) que+=NBElmt(Q)*(t-pret);
								printf("waktu kedatangan = %d, waktu tunggu = %d, Q = ",n,t-n);
								PrintQueue(Q);
								srvtime += t-n;
							}
			}
			pret=t;
		}
	}while(!close || !IsEmpty(Q));

	printf("\nBank tutup pada t = %d, layanan selesai pada t = %d\n",tclose,t);
	if(visitor) {
		printf("Jumlah pengunjung dilayani: %d orang\n",visitor);
		printf("Waktu tunggu rata-rata: %.0f satuan waktu\n",srvtime/visitor);
		printf("Panjang antrian rata-rata: %.3f orang\n",que/tclose);
	} else printf("Tidak ada pengunjung yang dilayani\n");
	
	return 0;	
}
Esempio n. 26
0
    const char *ExpectNext() {
        if (IsEmpty())
            UsageError();

        return GetNext();
    }
Esempio n. 27
0
void MyProduceConsume::Consume() {
    if (!IsEmpty()) {
        printf("pop %d\n", Front());
        Pop();
    }
}
Esempio n. 28
0
 void ExpectEnd() {
     if (!IsEmpty())
         UsageError();
 }
Esempio n. 29
0
bool MyProduceConsume::Condition() {
    return IsEmpty() == false;
}
Esempio n. 30
0
/*---FUNCTION TO EVALUATE POSTFIX EXPRESSION---*/
float evaluate(List Postfix_l)
{
	int i,count;
	count = Lexicon.count;
	char a[20];
	float x,y,f;
	KindType type;

	Stack_f S;
	S = CreateStack_f();
	while(!IsEmpty(Postfix_l))
	{
		Gettoken(a,Postfix_l);
		switch(type = kind(a))
		{
			case OPERAND:
				i = get_count(a);
				if(i > count)
				{
					puts("var not declared");
					exit(1004);
				}
				if(Lexicon.Entry[i].str!=NULL)
				{
					puts("var has no number value");
					exit(1005);
				}

				f = Lexicon.Entry[i].info.val;
				Push_f(f,S);
				break;
			case UNARYOP:
				f = TopandPop_f(S);
				f = DoUnary(f,a);
				Push_f(f,S);
				break;
			case BINARYOP:
				y = TopandPop_f(S);
				x = TopandPop_f(S);

				f = DoBinary(x,y,a);
				Push_f(f,S);
				break;
		}
	}
	
	if(IsEmpty_f(S))
	{
		puts("INVALID EXPRESSION");
		exit(1005);
	}

	f = TopandPop_f(S);

	if(!IsEmpty_f(S))
	{
		puts("INVALID EXPRESSION");
		       exit(1005);
	}

		
	return f;
}