int bt_insert (BtTree_s *tree, u64 key) { FN; BtNode_s *node; BtNode_s *parent; node = tree->root; if (!node) { tree->root = new_leaf(); leaf_insert(tree->root, key); ++tree->stat.num_inserts; return 0; } if (is_full(node)) { node = tree->root = grow(node); } for (;;) { if (node->is_leaf) { leaf_insert(node, key); ++tree->stat.num_inserts; return 0; } parent = node; node = lookup(node, key); if (is_full(node)) { node = split(parent, node); } } }
void test_is_full(void) { int value1 = 1; int value2 = 2; int value3 = 3; enqueue(queues, value1); enqueue(queues, value2); TEST_ASSERT_TRUE(is_full()); dequeue(queues); enqueue(queues, value3); TEST_ASSERT_TRUE(is_full()); }
/** * @internal * @param pg Formatted vbi_page to be optimized. * @param column First column, 0 ... pg->columns - 1. * @param row First row, 0 ... pg->rows - 1. * @param width Number of columns to optimize, 1 ... pg->columns. * @param height Number of rows to optimize, 1 ... pg->rows. * * Experimental. */ void vbi_optimize_page(vbi_page *pg, int column, int row, int width, int height) { vbi_char c, l, *cp; int column0, row0; int column1, row1; column0 = column; row0 = row; column1 = column + width; row1 = row + height; l = pg->text[pg->columns * row + column]; for (row = row0; row < row1; row++) for (column = column0; column < column1; column++) { cp = pg->text + pg->columns * row + column; c = *cp; if (is_blank(c)) { c.bold = l.bold; c.italic = l.italic; c.foreground = l.foreground; } else if (is_full(c)) { c.bold = l.bold; c.italic = l.italic; c.background = l.background; } *cp = l = c; } for (row = row1 - 1; row >= row0; row--) for (column = column1 - 1; column >= column0; column--) { cp = pg->text + pg->columns * row + column; c = *cp; if (is_blank(c)) { c.bold = l.bold; c.italic = l.italic; c.foreground = l.foreground; } else if (is_full(c)) { c.bold = l.bold; c.italic = l.italic; c.background = l.background; } *cp = l = c; } }
/** * @brief Displays the dialog box on a surface. * @param destination_surface the surface */ void DialogBox::display(Surface* destination_surface) { int x = box_dst_position.get_x(); int y = box_dst_position.get_y(); dialog_surface.fill_with_color(Color::get_black()); if (style == STYLE_WITHOUT_FRAME) { // display a dark rectangle destination_surface->fill_with_color(Color::get_black(), box_dst_position); } else { // display the dialog box box_img.blit(box_src_position, &dialog_surface, box_dst_position); } // display the text for (int i = 0; i < nb_visible_lines; i++) { line_surfaces[i]->display(&dialog_surface); } // display the icon if (icon_number != -1) { Rectangle src_position(0, 0, 16, 16); src_position.set_xy(16 * (icon_number % 10), 16 * (icon_number / 10)); icons_img.blit(src_position, &dialog_surface, icon_dst_position); question_dst_position.set_x(x + 50); } else { question_dst_position.set_x(x + 18); } // display the question arrow if (dialog.is_question() && is_full() && !has_more_lines()) { box_img.blit(question_src_position, &dialog_surface, question_dst_position); } // display the end message arrow if (is_full()) { end_lines_sprite.display(&dialog_surface, x + 103, y + 56); } // final blit dialog_surface.blit(destination_surface); }
void CSetChooserCache::insert(HeapRegion *hr) { guarantee(false, "CSetChooserCache::insert(): don't call this any more"); assert(!is_full(), "cache should not be empty"); hr->calc_gc_efficiency(); int empty_index; if (_occupancy == 0) { empty_index = _first; } else { empty_index = trim_index(_first + _occupancy); assert(_cache[empty_index] == NULL, "last slot should be empty"); int last_index = trim_index(empty_index - 1); HeapRegion *last = _cache[last_index]; assert(last != NULL,"as the cache is not empty, last should not be empty"); while (empty_index != _first && last->gc_efficiency() < hr->gc_efficiency()) { _cache[empty_index] = last; last->set_sort_index(get_sort_index(empty_index)); empty_index = last_index; last_index = trim_index(last_index - 1); last = _cache[last_index]; } } _cache[empty_index] = hr; hr->set_sort_index(get_sort_index(empty_index)); ++_occupancy; assert(verify(), "cache should be consistent"); }
void push(char c) { if(is_full()) { stack_overflow(); } else { contents[top++] = c; } }
/** * @brief Updates the dialog box. * * This function is called repeatedly by the game * while the dialog box exists. */ void DialogBox::update() { if (!is_enabled()) { return; // nothing to update } // update the text displaying update_lines(); // handle the end of the visible lines if (is_full()) { // update the message end arrow end_lines_sprite.update(); // show the appropriate action icon KeysEffect& keys_effect = game.get_keys_effect(); if (!end_lines_sprite.is_animation_started()) { if (has_more_lines() || dialog.has_next() || dialog.is_question()) { end_lines_sprite.set_current_animation("next"); keys_effect.set_action_key_effect(KeysEffect::ACTION_KEY_NEXT); } else { keys_effect.set_action_key_effect(KeysEffect::ACTION_KEY_RETURN); end_lines_sprite.set_current_animation("last"); } keys_effect.set_sword_key_effect(KeysEffect::SWORD_KEY_HIDDEN); Sound::play("message_end"); } } }
void ninsert(int pos, int num) { if (pos < 0 || pos >= MAX_SIZE || pos > length()) { printf("pos is invaild, %s failed.\n", __FUNCTION__); return; } if (length() == MAX_SIZE) { return is_full(); } int i = rear, j, count = length() - pos; while (count > 0) { j = (i + 1) % MAX_SIZE; circle[j] = circle[i]; i = (i - 1 + MAX_SIZE) % MAX_SIZE; count--; } rear = (rear + 1) % MAX_SIZE; circle[pos] = num; }
static void flush_icf_block(struct isal_zstream *stream) { struct isal_zstate *state = &stream->internal_state; struct level_2_buf *level_buf = (struct level_2_buf *)stream->level_buf; struct BitBuf2 *write_buf = &state->bitbuf; struct deflate_icf *icf_buf_encoded_next; set_buf(write_buf, stream->next_out, stream->avail_out); #if defined (USE_BITBUF8) || (USE_BITBUF_ELSE) if (!is_full(write_buf)) flush_bits(write_buf); #endif icf_buf_encoded_next = encode_deflate_icf(level_buf->icf_buf_start + state->count, level_buf->icf_buf_next, write_buf, &level_buf->encode_tables); state->count = icf_buf_encoded_next - level_buf->icf_buf_start; stream->next_out = buffer_ptr(write_buf); stream->total_out += buffer_used(write_buf); stream->avail_out -= buffer_used(write_buf); if (level_buf->icf_buf_next <= icf_buf_encoded_next) { state->count = 0; if (stream->avail_in == 0 && stream->end_of_stream) state->state = ZSTATE_TRL; else if (stream->avail_in == 0 && stream->flush != NO_FLUSH) state->state = ZSTATE_SYNC_FLUSH; else state->state = ZSTATE_NEW_HDR; } }
void push(char i) { if (is_full()) stack_overflow(); else contents[top++] = i; }
static void kbd_int(int irq, void *dummy, struct pt_regs *regs) { unsigned long flags; unsigned char scancode = 0; int i; static int upper = 0; cli(); save_flags(flags); scancode = read_code(); keyboard_stop(); if (scancode == 0xf0 || scancode == 0xe0) { scancode = read_code(); /* only capslock style at the moment */ } else if ( scancode == 0x12 || scancode == 0x59) { upper = upper ? 0 : 1; } if(get_ascii(scancode) && !is_full()) { buf[in] = upper ? get_ASCII(scancode) : get_ascii(scancode); in = (in+1) % BUFLEN; wake_up(&keypress_wait); } keyboard_start(); restore_flags(flags); }
/** * @brief Updates displaying the characters in the 3 lines. */ void DialogBox::update_lines() { uint32_t now = System::now(); while (!is_full() && now >= next_char_date) { // check the end of the current line while (!is_full() && char_index >= lines[line_index].size()) { char_index = 0; line_index++; } if (!is_full()) { add_character(); } } }
/* ** push */ void push( STACK_TYPE value ) { assert( !is_full() ); top_element += 1; stack[ top_element ] = value; }
int maxNode(char * board) //player1 { char evaluation = INF; if (is_winner(board, PLAYER_1)) evaluation=1; else if (is_full(board)) evaluation=0; else { //µ±Ç°½áµã¹ÀÖµ char temp; for (int i = 0; i < BOARD; i++) { if (board[i] == 0) { board[i] = PLAYER_2; temp = minNode(board); if (temp < evaluation) evaluation = temp; //×îС¹ÀÖµ board[i] = 0; //»Ö¸´µ±Ç°×´Ì¬ } } } #if DEBUG printBoard(board); printf("%d\n", evaluation); #endif return evaluation; }
void thread_queue::enqueue(const video_frame& fr) { if (is_full()) { size_t new_cap = m_capacity * 1.2 + 5; const video_frame** new_storage = (const video_frame**)malloc(sizeof (const video_frame*) * new_cap); if (head < tail) { memcpy(new_storage, m_storage + head, sizeof (const video_frame*) * size()); } else { memcpy(new_storage, m_storage + head, sizeof (const video_frame*) * (m_capacity - head)); memcpy(new_storage + m_capacity - head, m_storage, sizeof (const video_frame*) * tail); } head = 0; tail = size(); m_capacity = new_cap; free(m_storage); m_storage = new_storage; } m_storage[tail++] = &fr; if (tail == capacity()) { tail = 0; } }
void enqueue(struct queue* p_queue,int num) { if(!p_queue) { printf("%s line:%dCan't init! You passed NULL into this function\n",__FUNCTION__,__LINE__); return ; } if(is_full(p_queue) == FULL_QUEUE) { printf("ATTENTION! enqueue() failed. The queue is FULL now.\n"); return ; } (p_queue->tail)--; /* ** Circular array */ if(p_queue->tail < 0) { p_queue->tail = p_queue->capacity-1; } (p_queue->size)++; p_queue->array[p_queue->tail] = num; }
void ElementaryStream::push(DemuxerStream& stream, u32 sz, PesHeader& pes) { std::lock_guard<std::mutex> lock(m_mutex); if (is_full()) { cellDmux->Error("es::push(): buffer is full"); Emu.Pause(); return; } u32 data_addr = put + 128 + size; size += sz; memcpy(vm::get_ptr<void>(data_addr), vm::get_ptr<void>(stream.addr), sz); stream.skip(sz); auto info = vm::ptr<CellDmuxAuInfoEx>::make(put); info->auAddr = put + 128; info->auSize = size; if (pes.new_au) { info->dts.lower = (u32)pes.dts; info->dts.upper = (u32)(pes.dts >> 32); info->pts.lower = (u32)pes.pts; info->pts.upper = (u32)(pes.pts >> 32); info->isRap = false; // TODO: set valid value info->reserved = 0; info->userData = stream.userdata; }
void push(int i) { if(is_full()) printf("stack overflow. The imput is not balanced."); else contents[top++]=i; }
void push(int i) { if(is_full()) printf("stack overflow"); else contents[top++]=i; }
void enqueue (QueueType *q, char * client) { //큐에 삽입 if(is_full(q)) { error("대기인원이 만원입니다."); } q->rear = (q->rear+1)%MAX_QUEUE_SIZE; strcpy(q->client[q->rear], client); }
HandRank EvaluateHand(int hand[5]) { int rankcount[13]= {0}; for (int i=0; i< 5; i++) rankcount[RANK(hand[i])]++; if (is_royal(hand)) return eRoyal; if (is_straight_flush(hand, rankcount)) return eStraightFlush; if (is_four(rankcount)) return eFour; if (is_full(rankcount)) return eFull; if (is_flush(hand)) return eFlush; if (is_straight(rankcount)) return eStraight; if (is_three(rankcount)) return eThree; if (is_TwoPair(rankcount)) return eTwoPair; if (is_Pair(rankcount)) return ePair; return eBust; }
void enqueue(int *queues, int element) { if (is_full()) { queues = queue_full(queues, rear, front); } queues[++rear] = element; rear = rear % max_size; }
int main(void) { char ch; printf("Enter parentheses and/or braces: "); make_empty(); while (nested && !is_full()) { ch = getchar(); if (ch == '(' || ch == '{') push(ch); else if (ch == ')') { if (pop() != '(') nested = false; } else if (ch == '}') { if (pop() != '{') nested = false; } else if (ch == '\n') { if (!is_empty) nested = false; break; } } if (nested) printf("Parenteses/braces are nested properly\n"); else printf("Parenteses/braces are not nestes properly\n"); return 0; }
//-------------------------------------------------------------------------- void push_tail() { assert (!is_full()); m_size += m_entry_size; m_tail += m_entry_size; m_tail = (m_tail < (m_mem + m_total_size)) ? m_tail : m_mem; }
void push(int data) { // 스택에 데이터를 넣는다 if (is_full()) { // 스택이 가득차 데이터를 넣을 수 없다면 예외 처리한다 throw Exception("스택이 가득 찼습니다."); } // 스택의 마지막에 데이터를 넣고 크기를 증가시킨다 list[_count++] = data; }
void push(int digit) { if(is_full()) stack_overflow(); else stack[top++] = digit; }
// 삽입 함수 void enqueue(QueueType *q, element item) { if( is_full(q) ) error("큐가 포화상태입니다"); q->rear = (q->rear+1) % MAX_QUEUE_SIZE; q->queue[q->rear] = item; }
void insert(element_t x, heap_t q) { if (!is_full(q)) { q->array[++q->size] = x; swim(q->size, q); } }
static void try_add_result(struct list *list, unsigned relevance, char *name) { struct result *result, *r; assert(list != NULL); if (relevance == 0) return; result = new_result(list, relevance, name); if (is_empty(list)) return insert_before(list, NULL, result); /* * We know the list is not empty and therefor list->last is set. * If the list is not full just add the result at the end. */ if (cmp_results(list->last, result) > 0) { if (!is_full(list)) insert_before(list, NULL, result); return; } /* * Insert the result in a sorted manner */ for (r = list->first; r; r = r->next) if (cmp_results(r, result) < 0) break; insert_before(list, r, result); }
void push(int i) { if (is_full()) { stack_overflow(); } else { contents[top++] = i; } }