Esempio n. 1
1
void test_queue3(queue_t q, queue_pfcompare_t pf){
    queue_append(q, &c);
    queue_append(q, &c);
    queue_append(q, &c);
    queue_reverse(q);
    queue_sort(q, pf);
    queue_link_t cur = q->head;
    int k = 0;
    while(k < 3){
        if(*(int*)cur->e != 2){
            puts("test_queue3 failed @ line 227");
        }
        k++;
        cur = cur->next;
    }
    queue_element_t e = NULL;

    queue_remove(q, &e);
    queue_remove(q, &e);
    queue_remove(q, &e);
    if(queue_size(q) != 0)
        puts("test_queue3 failed @ line 238");
    if(q->head != NULL)
        puts("test_queue3 failes @ line 240");
}
Esempio n. 2
0
void Container::_notification(int p_what) {

    switch(p_what) {

    case NOTIFICATION_ENTER_TREE: {
        pending_sort=false;
        queue_sort();
    }
    break;
    case NOTIFICATION_RESIZED: {

        queue_sort();
    }
    break;
    case NOTIFICATION_THEME_CHANGED: {

        queue_sort();
    }
    break;
    case NOTIFICATION_VISIBILITY_CHANGED: {

        if (is_visible()) {
            queue_sort();
        }
    }
    break;
    }
}
Esempio n. 3
0
void Container::move_child_notify(Node *p_child) {

	if (!p_child->cast_to<Control>())
		return;

	queue_sort();
}
Esempio n. 4
0
void GridContainer::set_columns(int p_columns) {

	columns=p_columns;
	queue_sort();
	minimum_size_changed();

}
Esempio n. 5
0
void Container::_child_minsize_changed() {

	Size2 ms = get_combined_minimum_size();
	if (ms.width > get_size().width || ms.height > get_size().height)
		minimum_size_changed();
	queue_sort();
}
Esempio n. 6
0
void SplitContainer::set_split_offset(int p_offset) {

	if (expand_ofs==p_offset)
		return;
	expand_ofs=p_offset;
	queue_sort();
}
Esempio n. 7
0
void SplitContainer::set_collapsed(bool p_collapsed) {

	if (collapsed==p_collapsed)
		return;
	collapsed=p_collapsed;
	queue_sort();

}
Esempio n. 8
0
void ScrollContainer::_scroll_moved(float) {

	scroll.x=h_scroll->get_val();
	scroll.y=v_scroll->get_val();
	queue_sort();

	update();
};
Esempio n. 9
0
void test_queue5(queue_t q, queue_pfcompare_t pf){
    queue_append(q, &a);
    queue_reverse(q);
    queue_sort(q, pf);
    queue_element_t e = NULL;
    queue_remove(q, &e);
    if(queue_size(q) != 0)
        puts("test_queue5 failed @ line 289");
    if(q->head != NULL)
        puts("test_queue5 failes @ line 291");
}
Esempio n. 10
0
void Container::remove_child_notify(Node *p_child) {


	Control *control = p_child->cast_to<Control>();
	if (!control)
		return;

	control->disconnect("size_flags_changed",this,"queue_sort");
	control->disconnect("minimum_size_changed",this,"_child_minsize_changed");
	control->disconnect("visibility_changed",this,"_child_minsize_changed");
	queue_sort();
}
Esempio n. 11
0
void SplitContainer::_input_event(const InputEvent& p_event) {

	if (collapsed || !_getch(0) || !_getch(1) || !dragger_visible)
		return;

	if (p_event.type==InputEvent::MOUSE_BUTTON) {

		const InputEventMouseButton &mb=p_event.mouse_button;

		if (mb.button_index==BUTTON_LEFT) {

			if (mb.pressed) {
				int sep=get_constant("separation");

				if (vertical) {


					if (mb.y > middle_sep && mb.y < middle_sep+sep) {
						dragging=true;
						drag_from=mb.y;
						drag_ofs=expand_ofs;
					}
				} else {

					if (mb.x > middle_sep && mb.x < middle_sep+sep) {
						dragging=true;
						drag_from=mb.x;
						drag_ofs=expand_ofs;
					}
				}
			} else {

				dragging=false;
			}

		}
	}

	if (p_event.type==InputEvent::MOUSE_MOTION) {

		const InputEventMouseMotion &mm=p_event.mouse_motion;

		if (dragging) {

			expand_ofs=drag_ofs+((vertical?mm.y:mm.x)-drag_from);
			queue_sort();
			emit_signal("dragged",get_split_offset());
		}
	}

}
Esempio n. 12
0
File: main.c Progetto: Eaeth/myNCCL
int main(int argc, char *argv[])
{
	int i;
	Queue queue;

	queue_init(&queue);
	for (i = 1; i < argc; i ++) {
		parser_all_files(&queue, argv[i]); 
	}
	queue_sort(&queue, com_sort);
	show_result(&queue);
	queue_destroy(&queue);
	return 0;
}
Esempio n. 13
0
void test_sort(int* errors) {
    char* location = "test_sort";

    queue* q = queue_create();

    confirm_size(q, 0, location, errors);
    queue_sort(q, &compare);
    queue_element* expected0[] = {};
    confirm_order(q, expected0, location, errors);

    int x = 0;
    int y = 1;
    int z = 2;
    confirm_append(q, &x, 1, location, errors);
    queue_sort(q, &compare);
    queue_element* expected1[] = {&x};
    confirm_order(q, expected1, location, errors);

    confirm_append(q, &y, 2, location, errors);
    queue_sort(q, &compare);
    queue_element* expected2[] = {&x, &y};
    confirm_order(q, expected2, location, errors);

    confirm_append(q, &z, 3, location, errors);
    queue_sort(q, &compare);
    queue_element* expected3[] = {&x, &y, &z};
    confirm_order(q, expected3, location, errors);

    confirm_append(q, &x, 4, location, errors);
    queue_sort(q, &compare);
    queue_element* expected4[] = {&x, &x, &y, &z};
    confirm_order(q, expected4, location, errors);

    queue_destroy(q);
    q = NULL;
}
Esempio n. 14
0
void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {

	if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility != DRAGGER_VISIBLE)
		return;

	Ref<InputEventMouseButton> mb = p_event;

	if (mb.is_valid()) {

		if (mb->get_button_index() == BUTTON_LEFT) {

			if (mb->is_pressed()) {

				int sep = get_constant("separation");

				if (vertical) {

					if (mb->get_position().y > middle_sep && mb->get_position().y < middle_sep + sep) {

						dragging = true;
						drag_from = mb->get_position().y;
						drag_ofs = expand_ofs;
					}
				} else {

					if (mb->get_position().x > middle_sep && mb->get_position().x < middle_sep + sep) {

						dragging = true;
						drag_from = mb->get_position().x;
						drag_ofs = expand_ofs;
					}
				}
			} else {

				dragging = false;
			}
		}
	}

	Ref<InputEventMouseMotion> mm = p_event;

	if (mm.is_valid() && dragging) {

		expand_ofs = drag_ofs + ((vertical ? mm->get_position().y : mm->get_position().x) - drag_from);
		queue_sort();
		emit_signal("dragged", get_split_offset());
	}
}
Esempio n. 15
0
void test_queue4(queue_t q, queue_pfcompare_t pf){
    queue_append(q, &b);
    queue_append(q, &c);
    queue_append(q, &d);
    queue_append(q, &a);
    queue_reverse(q);
    queue_link_t cur = q->head;
    int k = 0;
      while(k < 4){
        if(k == 0 && *(int*)cur->e != 0) puts("test_queue3 failed @ line 252");
        if(k == 1 && *(int*)cur->e != -4) puts("test_queue3 failed @ line 253");
        if(k == 2 && *(int*)cur->e != 2) puts("test_queue3 failed @ line 254");
        if(k == 3 && *(int*)cur->e != 1) puts("test_queue3 failed @ line 255");
        k++;
        cur = cur->next;
    }
    cur = q->head;
    queue_sort(q, pf);
    k = 0;
    while(k < 4){
        if(k == 0 && *(int*)cur->e != -4) puts("test_queue2 failed @ line 263");
        if(k == 1 && *(int*)cur->e != 0) puts("test_queue2 failed @ line 264");
        if(k == 2 && *(int*)cur->e != 1) puts("test_queue2 failed @ line 265");
        if(k == 3 && *(int*)cur->e != 2) puts("test_queue2 failed @ line 266");
        k++;
        cur = cur->next;
    }
    queue_element_t e = NULL;

    queue_remove(q, &e);
    queue_remove(q, &e);
    queue_remove(q, &e);
    queue_remove(q, &e);
    if(queue_size(q) != 0)
        puts("test_queue4 failed @ line 277");
    if(q->head != NULL)
        puts("test_queue4 failes @ line 279");
}
Esempio n. 16
0
int sort_test(){
  queue* q = queue_create();
  int w = 506;
  int x = -5466;
  int y = 90000;
  int z = 0;
  queue_append(q, &w);
  queue_append(q, &z);
  queue_append(q, &x);
  queue_append(q, &y);
  queue_append(q, &z);
  assert(queue_size(q) == 5);
  int *ret_val;
  queue_sort(q, &queue_comp);
  queue_remove(q, (queue_element **)&ret_val); 
  int prev = *ret_val;
  while(!queue_is_empty(q)){
    queue_remove(q, (queue_element **)&ret_val); 
    assert(prev <= *ret_val);
    prev = *ret_val;
  }
  queue_destroy(q,false);
  return 0;
}
Esempio n. 17
0
void SplitContainer::set_dragger_visible(bool p_true) {

	dragger_visible=p_true;
	queue_sort();
	update();
}
Esempio n. 18
0
void GridContainer::set_columns(int p_columns) {

	columns=p_columns;
	queue_sort();

}
Esempio n. 19
0
int main() {
    int i = 0;
    char c;

    queue_t* firstQueue = queue_create();
    queue_t* secondQueue = queue_create();

    while (1) {
        scanf("%c", &c);
        if (c == '+') {
            scanf("%c", &c);

            if (c == '1') {
                firstQueue = queue_add(firstQueue);
            }
            if (c == '2') {
                secondQueue = queue_add(secondQueue);
            }
        }
        if (c == '-') {
            scanf("%c", &c);

            if (c == '1') {
                firstQueue = queue_del(firstQueue);
            }
            if (c == '2') {
                secondQueue = queue_del(secondQueue);
            }
        }
        if (c == 'c') {
            firstQueue = queue_concat(firstQueue, secondQueue);

            /** WARNING: ????
             * Возможно тут имелось ввиду освобождение памяти?
             */
            secondQueue = NULL;
            secondQueue = queue_create();
        }
        if (c == 's') {
            scanf("%c", &c);

            if (c == '1') {
                firstQueue = queue_sort(firstQueue);
            }
            if (c == '2') {
                secondQueue = queue_sort(secondQueue);
            }
        }
        if (c == 'q') {
            printf("Bye\n");
            break;
        }
        if (c == 'p') {
            scanf("%c", &c);
            if (c == '1')
                queue_print(firstQueue);
            if (c == '2')
                queue_print(secondQueue);
        }
    }

    return 0;
}
Esempio n. 20
0
queue_t
*read_rbfsum2 (char *buffer)
{
  queue_t *list = NULL;
  char *tmp = buffer;
  char *name;
  char *start, *end;
  char *file_line;
  char *line;
  rbfsum_t rb;
  unsigned int id;
  station_data_t *data;

  while (*tmp)
    {
      file_line = get_line (tmp);
      if (!file_line)
        {
          tmp = next_line (tmp);
          continue;
        }

      if (*file_line == '/')
        {
          start = strrchr (file_line, '/');
          start++;
          end = strrchr (start, '.');
          if (!end)
            {
              tmp = next_line (tmp);
              continue;
            }

          name = xstrndup (start + 1, end - start - 1);
          free (file_line);

          tmp = next_line (tmp);
          if (*tmp == '\0')
            {
              free (name);
              break;
            }

          tmp = next_line (tmp);
          if (*tmp == '\0')
            {
              free (name);
              break;
            }

          data = malloc (sizeof(station_data_t));
          data->name = name;

          id = 0;
          while ((line = get_line (tmp)))
            {
              if (parse_data (line, &rb))
                {
                  memcpy (&data->rs[id], &rb, sizeof(rb));
                  id++;
                }
              free (line);
              tmp = next_line (tmp);
            }
          data->ndata = id;
          list = queue_prepend (list, data);
        }
      tmp = next_line (tmp);
    }

  list = queue_sort (list, comp_func);
  return list;
}
Esempio n. 21
0
void CenterContainer::set_use_top_left(bool p_enable) {

	use_top_left=p_enable;
	queue_sort();

}
Esempio n. 22
0
void SplitContainer::set_dragger_visibility(DraggerVisibility p_visibility) {

	dragger_visibility = p_visibility;
	queue_sort();
	update();
}
Esempio n. 23
0
void ViewportContainer::set_stretch(bool p_enable) {

	stretch = p_enable;
	queue_sort();
	update();
}
Esempio n. 24
0
void ScrollContainer::set_enable_v_scroll(bool p_enable) {

	scroll_v=p_enable;
	queue_sort();
}