/** * Test the first stack is less than the second stack. */ bool_t stack_less(const cstl_stack_t* cpsk_first, const cstl_stack_t* cpsk_second) { assert(cpsk_first != NULL); assert(cpsk_second != NULL); #if defined (CSTL_STACK_VECTOR_SEQUENCE) return vector_less(&cpsk_first->_t_sequence, &cpsk_second->_t_sequence); #elif defined (CSTL_STACK_LIST_SEQUENCE) return list_less(&cpsk_first->_t_sequence, &cpsk_second->_t_sequence); #else return deque_less(&cpsk_first->_t_sequence, &cpsk_second->_t_sequence); #endif }
/** * Test the first vector is greater than the second vector. */ bool_t vector_greater(const vector_t* cpvec_first, const vector_t* cpvec_second) { return vector_less(cpvec_second, cpvec_first); }
/** * Test the first vector is less than or equal to the second vector. */ bool_t vector_less_equal(const vector_t* cpvec_first, const vector_t* cpvec_second) { return (vector_less(cpvec_first, cpvec_second) || vector_equal(cpvec_first, cpvec_second)) ? true : false; }
void _type_less_priority_queue(const void* cpv_first, const void* cpv_second, void* pv_output) { assert(cpv_first != NULL && cpv_second != NULL && pv_output != NULL); *(bool_t*)pv_output = vector_less(&((priority_queue_t*)cpv_first)->_vec_base, &((priority_queue_t*)cpv_second)->_vec_base); }
void _type_less_vector(const void* cpv_first, const void* cpv_second, void* pv_output) { assert(cpv_first != NULL && cpv_second != NULL && pv_output != NULL); *(bool_t*)pv_output = vector_less((vector_t*)cpv_first, (vector_t*)cpv_second); }
int t_vector() { c_vector vt; __c_vector(&vt, int_comparer); printf("1.test create vector\n"); create_with_push_back(&vt); print_vector(&vt); reverse_print_vector(&vt); clear_vector(&vt); printf("\n\n2.test vector assign\n"); create_with_push_back(&vt); vector_assign(&vt); clear_vector(&vt); printf("\n\n3.test erase vector\n"); erase_vector(); printf("\n\n4.test reserve vector\n"); create_with_push_back(&vt); vector_reserve(&vt); clear_vector(&vt); printf("\n\n5.test front back\n"); create_with_push_back(&vt); vector_front_back(&vt); clear_vector(&vt); printf("\n\n6.test swap\n"); create_with_push_back(&vt); vector_swap(&vt); clear_vector(&vt); printf("\n\n7.test insert\n"); vector_insert(&vt); clear_vector(&vt); printf("\n\n8.test insert2\n"); create_with_push_back(&vt); vector_insert2(&vt); clear_vector(&vt); printf("\n\n9.test fill insert\n"); create_with_push_back(&vt); vector_fill_insert(&vt); clear_vector(&vt); printf("\n\n10.test resize\n"); create_with_push_back(&vt); vector_resize(&vt); clear_vector(&vt); printf("\n\n11.test equal\n"); create_with_push_back(&vt); vector_equal(&vt); clear_vector(&vt); printf("\n\n12.test less\n"); create_with_push_back(&vt); vector_less(&vt); clear_vector(&vt); __c_rotcev(&vt); printf("\n\nfinish testing vector!\n"); return 0; }