コード例 #1
0
ファイル: circular_buffer.hpp プロジェクト: endowataru/mgbase
 void push_front(const T& val)
 {
     MGBASE_ASSERT(!full());
     ++size_;
     
     decrement(&first_);
     
     // Copy the value after decrement.
     data()[first_] = val;
 }
コード例 #2
0
ファイル: 146.C プロジェクト: JackDrogon/Study
void main()
{int gd=VGA,gm=VGALO;
 /*registerbgidriver(EGAVGA_driver);*/
 initgraph(&gd,&gm,"e:\\tc\\bgi"); /*设置图形模式*/
 setcolor(YELLOW);
 rectangle(105,105,175,135); /*画正方形*/
 full(120,120,YELLOW); /*调填充函数*/
 getch(); /*等待*/
 closegraph(); /*关闭图形模式*/
}
コード例 #3
0
void QProgressBarPlus::unitTimeout() {
    this->setValue(this->value() + 1);
    if(this->value() >= 100) {
        emit full();
    }
    else {
        this->timer->setInterval(unitInterval);
        this->timer->start();
    }
}
コード例 #4
0
ファイル: circular_buffer.hpp プロジェクト: endowataru/mgbase
 void push_back(const T& val)
 {
     MGBASE_ASSERT(!full());
     ++size_;
     
     // Copy the value before increment.
     data()[last_] = val;
     
     increment(&last_);
 }
コード例 #5
0
ファイル: intopre.c プロジェクト: nit99kumar/algo_lab
/*Push Function Definition*/
void push(STK *s1,char elem)
{
if(!full(s1))
{
s1->top++;                  /*Incrementing top*/
s1->data[s1->top]=elem;     /*Storing element*/
}
else
printf("Stack is Full!");
}
コード例 #6
0
ファイル: MIXADT2.C プロジェクト: TVilaboa/ParseV2
void push(int top,int item[],int dato)
{
   if(!full(top,item))
   {
      (top)++;
      item[top]=dato;  //elemento[1]=dato
   }
   else
      printf("\nOVERFLOW");
}
コード例 #7
0
long CharStringBuffer::append(const char& c) {

	if ( full() ) {
		return 0;
	} else {
		contents[fill_point_marker] = c;
		fill_point_marker++;
		return 1;
	}
}
コード例 #8
0
ファイル: mainwindow.cpp プロジェクト: partition/qalambury
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->chatTimeout = true;
    this->connected = false;
    this->currColorId = 2; // czarny
    this->lastColorButton = ui->blackPushButton;
    this->graphicsScene = new QGraphicsScene();
    ui->graphicsView->setScene(graphicsScene);
    this->currentPen.setColor(QColor("black"));


    connect(ui->graphicsView,SIGNAL(drawPoint(QPoint)),this,SLOT(drawPoint(QPoint)));
    connect(ui->graphicsView,SIGNAL(drawLineTo(QPoint)),this,SLOT(drawLineTo(QPoint)));

    connect(ui->clearPushButton,SIGNAL(clicked()),this,SLOT(clearView()));
    connect(ui->redPushButton,SIGNAL(clicked()),this,SLOT(switchColor()));
    connect(ui->greenPushButton,SIGNAL(clicked()),this,SLOT(switchColor()));
    connect(ui->blackPushButton,SIGNAL(clicked()),this,SLOT(switchColor()));
    connect(ui->sendMessagePushButton,SIGNAL(clicked()),this,SLOT(sendMessage()));
    connect(ui->chatLineEdit,SIGNAL(returnPressed()),this,SLOT(sendMessage()));

    this->socket = new KalSocket();
    this->chatTimer = new QTimer();

    connect(socket,SIGNAL(connected()),this,SLOT(connectionSuccess()));
    connect(socket,SIGNAL(error(QAbstractSocket::SocketError)),
            this,SLOT(displayError(QAbstractSocket::SocketError)));
    connect(socket,SIGNAL(pointsReceived(int,int,int,KalSocket::DrawType)),
            this,SLOT(pointsReceived(int,int,int,KalSocket::DrawType)));
    connect(socket,SIGNAL(clear()),graphicsScene,SLOT(clear()));
    connect(socket,SIGNAL(someoneLoggedIn(QString)),this,SLOT(someoneLoggedIn(QString)));
    connect(socket,SIGNAL(chatMessage(QString,QString)),this,SLOT(addMessage(QString,QString)));
    connect(socket,SIGNAL(nicknames(QList<QString>)),this,SLOT(getNicknames(QList<QString>)));
    connect(socket,SIGNAL(logout(QString)),this,SLOT(someoneLoggedOut(QString)));
    connect(socket,SIGNAL(drawStart(QString)),this,SLOT(drawStart(QString)));
    connect(socket,SIGNAL(gotSettings(ServerSettings)),this,SLOT(getSettings(ServerSettings)));
    connect(socket,SIGNAL(errorMessage(QString)),this,SLOT(showMessage(QString)));

    connect(ui->wantDrawCheckBox,SIGNAL(toggled(bool)),this,SLOT(wantDrawToggled(bool)));

    // actiony z menu: Polaczenie
    connect(ui->actionPo_cz,SIGNAL(triggered()),this,SLOT(connectWindowExec())); // laczymy sie
    connect(ui->actionRoz_cz,SIGNAL(triggered()),this,SLOT(disconnect())); // rozlaczamy sie
    connect(ui->actionZako_cz,SIGNAL(triggered()),this,SLOT(close())); // koniec programu

    // timer
    connect(chatTimer,SIGNAL(timeout()),this,SLOT(timeout()));
    connect(ui->progressBar,SIGNAL(full()),this,SLOT(drawTimeout()));

    // inne
    this->disableActions(false); // Polacz - aktywne, Rozlacz - nieaktywne
}
コード例 #9
0
ファイル: th_movie.cpp プロジェクト: raurodse/CorsixTH
int THMoviePictureBuffer::write(AVFrame* pFrame, double dPts)
{
    THMoviePicture* pMoviePicture = nullptr;
    SDL_LockMutex(m_pMutex);
    while(full() && !m_fAborting)
    {
        SDL_CondWait(m_pCond, m_pMutex);
    }
    SDL_UnlockMutex(m_pMutex);
    if(m_fAborting) { return -1; }

    pMoviePicture = &m_aPictureQueue[m_iWriteIndex];
    SDL_LockMutex(pMoviePicture->m_pMutex);

    if(pMoviePicture->m_pTexture)
    {
        m_pSwsContext = sws_getCachedContext(m_pSwsContext, pFrame->width, pFrame->height, (PixelFormat)pFrame->format, pMoviePicture->m_iWidth, pMoviePicture->m_iHeight, pMoviePicture->m_pixelFormat, SWS_BICUBIC, nullptr, nullptr, nullptr);
        if(m_pSwsContext == nullptr)
        {
            SDL_UnlockMutex(m_aPictureQueue[m_iWriteIndex].m_pMutex);
            std::cerr << "Failed to initialize SwsContext\n";
            return 1;
        }

        /* Allocate a new frame and buffer for the destination RGB24 data. */
        AVFrame *pFrameRGB = av_frame_alloc();
        int numBytes = avpicture_get_size(pMoviePicture->m_pixelFormat, pMoviePicture->m_iWidth, pMoviePicture->m_iHeight);
        uint8_t *buffer = (uint8_t *)av_malloc(numBytes * sizeof(uint8_t));
        avpicture_fill((AVPicture *)pFrameRGB, buffer, pMoviePicture->m_pixelFormat, pMoviePicture->m_iWidth, pMoviePicture->m_iHeight);

        /* Rescale the frame data and convert it to RGB24. */
        sws_scale(m_pSwsContext, pFrame->data, pFrame->linesize, 0, pMoviePicture->m_iHeight, pFrameRGB->data, pFrameRGB->linesize);

        /* Upload it to the texture we render from - note that this works because our OpenGL context shares texture namespace with the main threads' context. */
        SDL_UpdateTexture(pMoviePicture->m_pTexture, nullptr, buffer, pMoviePicture->m_iWidth * 3);

        av_free(buffer);
        av_frame_free(&pFrameRGB);

        pMoviePicture->m_dPts = dPts;

        SDL_UnlockMutex(m_aPictureQueue[m_iWriteIndex].m_pMutex);
        m_iWriteIndex++;
        if(m_iWriteIndex == PICTURE_BUFFER_SIZE)
        {
            m_iWriteIndex = 0;
        }
        SDL_LockMutex(m_pMutex);
        m_iCount++;
        SDL_UnlockMutex(m_pMutex);
    }

    return 0;
}
コード例 #10
0
ファイル: ringbuffer.hpp プロジェクト: Tandrial/AI-SE-Bsc
void RingBuffer<T,size>::push_back(const T& elem) {
    // if there is no space left we silently drop the operation
    if (full())
        return;
    // back points to an empty space at the end of the queue, so we first set
    // the new element and then increase the pointer
    values[back] = elem;
    back = (back + 1) % size;
    // There is now one more element in the buffer
    count++;
}
コード例 #11
0
ファイル: theStack.cpp プロジェクト: eselkin/RPNC
void theStack::push(void *x, const char theType)
{
    if(full())
        throw sFULL;
    tos++; // we successfully are adding something to the stack

    // switch here
    node *newNext = new node(x, theType, anchor->next); // make a nodepointer with a node with key *x
    newNext->next = anchor->next; // put it into the head position and keep the others afterward
    anchor->next = newNext; // point anchor to it
}
コード例 #12
0
void put(stackentry1 item,stack1 *s)
{
if(full(s))
{
printf("stack full\n");
}
else
{
s->entry[s->top++]=item;
}
}
コード例 #13
0
void shutter::bulbStart(void)
{
    if(cable_connected == 0 && ir_shutter_state != 1)
    {
        ir_shutter_state = 1;
        ir.shutterNow();
//        ir.shutterDelayed();
    } 
    if(conf.bulbMode == 0)
    {
        full();
    } 
    else if(conf.bulbMode == 1 && shutter_state != 1)
    {
        full();
        shutter_state = 1;
        _delay_ms(75);
        half();
    }
}
コード例 #14
0
ファイル: BIDMat_CUMATD.cpp プロジェクト: Sandy4321/BIDMat
  JNIEXPORT jint JNICALL Java_edu_berkeley_bid_CUMATD_full
  (JNIEnv *env, jobject obj, jobject jir, jobject jic, jobject jdata, jobject jod,
   jint nrows, jint ncols, jint nnz)
  {
    int *ir = (int*)getPointer(env, jir);
    int *ic = (int*)getPointer(env, jic);
    double *data = (double*)getPointer(env, jdata);
    double *od = (double*)getPointer(env, jod);

    return full(ir, ic, data, od, nrows, ncols, nnz);
  }
コード例 #15
0
ファイル: stack.c プロジェクト: kizzlebot/Computer-Science-I
// If the push occurs, 1 is returned. If the
// stack is full and the push can't be done, 0 is
// returned.
int push(struct stack* stackPtr, int value) {

    // Check if the stack is full.
    if (full(stackPtr))
        return 0;

    // Add value to the top of the stack and adjust the value of the top.
    stackPtr->items[stackPtr->top+1] = value;
    (stackPtr->top)++;
    return 1;
}
コード例 #16
0
ファイル: 04arr_queue.c プロジェクト: Rovi/TarenaCode
//实现入队的基本操作
void push(Queue* pq,int data)
{
	//判断队列是否为满
	if(full(pq))
	{
		printf("队列已经满了,元素%d入队失败\n",data);
		return;//结束当前函数
	}
	pq->arr[(pq->front+pq->cnt)%pq->len] = data;
	++pq->cnt;
}
コード例 #17
0
ファイル: Store.cpp プロジェクト: KToshev/OOP
void Store::addElement(const Product& other)
{
    if(full())
    {
        cout<<"The store is full\n";
        exit(1);
    }
    products[size] = other;
    ptrs[size]  = &products[size];
    size++;
}
        void push_front(int ele)
        {
            if (full())
            {
                // deque is full, expansion code is omitted
            }

            _head = _head == 0 ? _capc - 1 : _head - 1;

            _data[_head] = ele;
        }
コード例 #19
0
ファイル: queue.hpp プロジェクト: fezhang/algorithms
void queue_array<Item>::put(Item item)
{
	if(full())
	{
		cout<<"Error in queue_array::put, buff is not enough!"<<endl;
		return;
	}
	m_pBase[m_posHead] = item;
	m_nDataLen += 1;
	m_posHead = (m_posHead+1)%m_nBuffLen;
};
        void push_back(int ele)
        {
            if (full())
            {
                // ommit expansion
            }

            _data[_tail] = ele;

            _tail = _tail + 1 == _capc ? 0 : _tail + 1;
        }
コード例 #21
0
ファイル: MyBuffer.cpp プロジェクト: Fransunshine/webEngine
void Buffer::push(MyTask *ptask)
{
	MutexLockGuard mtg(m_mutex);
	while(full())
	{
		m_notFull.wait();	
	}

	m_queue.push(ptask);
	m_notEmpty.notify();
}
コード例 #22
0
ファイル: gamehistory.cpp プロジェクト: isn0gud/qtMauMau
/**
 * writes a Text + the Card suit and value in the History doc
 * @brief GameHistory::write
 * @param text
 * @param suit
 * @param value
 */
void GameHistory::write(QString text, Card::cardSuit suit, Card::cardValue value)
{
    QString hand;
    Card c = Card(suit,value);
    CardItem item = CardItem(c);
    hand += cardToString(item);
    QString full(text + " - "+ hand);
    QTextStream out(file);
    out.setAutoDetectUnicode(true);
    out << full << "\n";
}
コード例 #23
0
ファイル: CBuffer.cpp プロジェクト: tex/preloadfs
void CBuffer::advance(int offset)
{
	assert(offset <= full());

	m_readP += offset;
	if (m_readP >= m_bufferSize)
		m_readP -= m_bufferSize;
	if (m_readP == m_writeP)
		m_empty = true;
	m_full = false;
}
コード例 #24
0
ファイル: ringbuffer.hpp プロジェクト: Tandrial/AI-SE-Bsc
void RingBuffer<T,size>::push_front(const T& elem) {
    // if there is no space left we silently drop the operation
    if (full())
        return;
    // since front is points directly to the first element, we first decrease
    // the pointer and then set the new element
    front = (front + size - 1) % size;
    values[front] = elem;
    // There is now one more element in the buffer
    count++;
}   
コード例 #25
0
ファイル: Stack.cpp プロジェクト: 4179e1/misc
bool
Stack::push (const string &elem)
{
	if (full())
	{
		return false;
	}

	_stack.push_back (elem);
	return true;
}
コード例 #26
0
ファイル: th_movie.cpp プロジェクト: J-Shep/CorsixTH
int THMoviePictureBuffer::write(AVFrame* pFrame, double dPts)
{
    THMoviePicture* pMoviePicture = nullptr;
    SDL_LockMutex(m_pMutex);
    while(full() && !m_fAborting)
    {
        SDL_CondWait(m_pCond, m_pMutex);
    }
    SDL_UnlockMutex(m_pMutex);
    if(m_fAborting) { return -1; }

    pMoviePicture = &m_aPictureQueue[m_iWriteIndex];
    SDL_LockMutex(pMoviePicture->m_pMutex);

    if(pMoviePicture->m_pBuffer)
    {
        m_pSwsContext = sws_getCachedContext(m_pSwsContext, pFrame->width, pFrame->height, (AVPixelFormat)pFrame->format, pMoviePicture->m_iWidth, pMoviePicture->m_iHeight, pMoviePicture->m_pixelFormat, SWS_BICUBIC, nullptr, nullptr, nullptr);
        if(m_pSwsContext == nullptr)
        {
            SDL_UnlockMutex(m_aPictureQueue[m_iWriteIndex].m_pMutex);
            std::cerr << "Failed to initialize SwsContext\n";
            return 1;
        }

        /* Allocate a new frame and buffer for the destination RGB24 data. */
        AVFrame *pFrameRGB = av_frame_alloc();
#if (defined(CORSIX_TH_USE_LIBAV) && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(54, 6, 0)) || \
    (defined(CORSIX_TH_USE_FFMPEG) && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 63, 100))
        av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, pMoviePicture->m_pBuffer, pMoviePicture->m_pixelFormat, pMoviePicture->m_iWidth, pMoviePicture->m_iHeight, 1);
#else
        avpicture_fill((AVPicture *)pFrameRGB, pMoviePicture->m_pBuffer, pMoviePicture->m_pixelFormat, pMoviePicture->m_iWidth, pMoviePicture->m_iHeight);
#endif

        /* Rescale the frame data and convert it to RGB24. */
        sws_scale(m_pSwsContext, pFrame->data, pFrame->linesize, 0, pFrame->height, pFrameRGB->data, pFrameRGB->linesize);

        av_frame_free(&pFrameRGB);

        pMoviePicture->m_dPts = dPts;

        SDL_UnlockMutex(m_aPictureQueue[m_iWriteIndex].m_pMutex);
        m_iWriteIndex++;
        if(m_iWriteIndex == ms_pictureBufferSize)
        {
            m_iWriteIndex = 0;
        }
        SDL_LockMutex(m_pMutex);
        m_iCount++;
        SDL_UnlockMutex(m_pMutex);
    }

    return 0;
}
コード例 #27
0
bool Queue_a::addq(qelement no)
{
	if(full())
		return 0;
	else
	{
		rear = (rear+1)%MAX;
		arr[rear]=no;
		count++;
		return 1;
	}
}
コード例 #28
0
bool DQ_a::addright(qelement no)
{
	if(full())
		return 0;
	else
	{
		rear=(rear+1)%MAX;
		arr[rear]=no;
		count++;
		return 1;
	}
}
コード例 #29
0
bool Adafruit_FIFO::write(void const* item)
{
  if ( full() && !m_overwritable ) return false;

  memcpy( m_buffer + (m_wr_idx * m_item_size),
          item,
          m_item_size);

  m_wr_idx = (m_wr_idx + 1) % m_depth;

  if ( full() )
  {
    m_rd_idx = m_wr_idx; // keep the full state (rd == wr && len = size)
  }
  else
  {
    m_count++;
  }

  return true;
}
コード例 #30
0
ファイル: fifo.cpp プロジェクト: kutenai/MSEE-Firmware
//! Push a new value onto the fifo. 
//! This function returns 0 if the operation succeeds, and a negative
//! value if the operation fails.
int8_t Fifo::push(FifoType* d) 
{
    if (full()) return -1;
    *(_end++) = *d;
    
    // Wrap the end back to the beginning.
    if ((_end - _pdata) > _size) {
        _end = _pdata;
    }

	return 0;
}