本文整理汇总了C++中List_new函数的典型用法代码示例。如果您正苦于以下问题:C++ List_new函数的具体用法?C++ List_new怎么用?C++ List_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了List_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IoObject_rawClonePrimitive
IoAudioMixer *IoAudioMixer_rawClone(IoAudioMixer *proto)
{
IoObject *self = IoObject_rawClonePrimitive(proto);
self->data = cpalloc(proto->data, sizeof(IoAudioMixerData));
DATA(self)->ioBuffer = IoSeq_new(IOSTATE);
DATA(self)->buffer = IoSeq_rawUArray(DATA(self)->ioBuffer);
DATA(proto)->mixBuffer = UArray_new();
DATA(self)->writeMessage =
IoMessage_newWithName_label_(IOSTATE,
IOSYMBOL("write"),
IOSYMBOL("AudioMixer"));
IoMessage_setCachedArg_to_(DATA(self)->writeMessage, 0, DATA(self)->ioBuffer);
DATA(self)->nonBlockingWriteMessage =
IoMessage_newWithName_label_(IOSTATE,
IOSYMBOL("nonBlockingWrite"),
IOSYMBOL("AudioMixer"));
IoMessage_setCachedArg_to_(DATA(self)->nonBlockingWriteMessage, 0, DATA(self)->ioBuffer);
DATA(self)->sounds = List_new();
DATA(self)->soundsToRemove = List_new();
DATA(self)->events = List_new();
DATA(self)->activeEvents = List_new();
DATA(self)->volume = DATA(self)->volume;
DATA(self)->soundTouch = SoundTouch_init();
SoundTouch_setSampleRate(DATA(self)->soundTouch, 44100);
SoundTouch_setChannels(DATA(self)->soundTouch, 2);
DATA(self)->tempo = 1.0;
IoState_addValue_(IOSTATE, self);
return self;
}
示例2: s16_svc_new
svc_t * s16_svc_new ()
{
svc_t * newSvc = calloc (1, sizeof (svc_t));
newSvc->properties = List_new ();
newSvc->instances = List_new ();
return newSvc;
}
示例3: Post_new
Post_t Post_new(int xCoord, int yCoord){
Post_t self = (Post_t) malloc(sizeof(struct Post));
self->wantedCars = List_new();
self->wantedCarEvents = List_new();
self->transists = List_new();
self->xCoord = xCoord;
self->yCoord = yCoord;
return self;
}
示例4: ASSERT
// Creates a new RULE CONDITION GRAPH - it creates a RCG node for every tuple variable
// Takes the tuple variable and the data source list along with the number of tuple variables
// as the input
RCG *RCG_new(int num_tuple_var, List *tuple_var_list, List *datasrc_list)
{
RCG *graph;
int i;
ListElement *cursor1, *cursor2;
RCG_node *node;
void *tuple_var_name, *datasrc_name;
ASSERT(tuple_var_list);
ASSERT(datasrc_list);
graph = (RCG *)tman_malloc(sizeof(RCG));
memset(graph, '\0', sizeof(RCG));
graph->type = RCG_TYPE;
graph->num_tuple_variables = num_tuple_var;
graph->nodes = List_new();
graph->catch_all = List_new();
if (!num_tuple_var)
{
/* The RCG does not have any tuple variables. For ex.
** when 1 = 1.
*/
return graph;
}
/* create the individual nodes -- one for each tuple variable*/
node = RCG_node_new();
tuple_var_name = (char *)List_getFirst(tuple_var_list, &cursor1);
datasrc_name = (char *)List_getFirst(datasrc_list, &cursor2);
node->tuple_variable_name = get_chars(tuple_var_name);
node->datasrc_name = get_chars(datasrc_name);
/* Insert the node into the RCG */
List_insertElement(graph->nodes, node);
for (i = 1; i < num_tuple_var; i++)
{
/* create the individual nodes */
node = RCG_node_new();
tuple_var_name = (char *)List_getNext(&cursor1);
datasrc_name = (char *)List_getNext(&cursor2);
node->tuple_variable_name = get_chars(tuple_var_name);
node->datasrc_name = get_chars(datasrc_name);
/* Insert the node into the RCG */
List_insertElement(graph->nodes, node);
}
return graph;
}
示例5: sizeof
IoLexer *IoLexer_new(void)
{
IoLexer *self = (IoLexer *)io_calloc(1, sizeof(IoLexer));
self->s = (char *)io_calloc(1, 1);
self->s[0] = 0;
self->posStack = Stack_new();
self->tokenStack = Stack_new();
self->tokenStream = List_new();
self->charLineIndex = List_new();
return self;
}
示例6: IoObject_rawClonePrimitive
IoODEWorld *IoODEWorld_rawClone(IoODEWorld *proto)
{
IoObject *self = IoObject_rawClonePrimitive(proto);
IoObject_setDataPointer_(self, calloc(1, sizeof(IoODEWorldData)));
WORLDID = dWorldCreate();
DATA(self)->bodies = List_new();
DATA(self)->jointGroups = List_new();
IoObject_inlineSetSlot_to_(self, IOSYMBOL("Body"), IoODEBody_newBodyProtoWithWorld(IOSTATE, self));
IoObject_inlineSetSlot_to_(self, IOSYMBOL("JointGroup"), IoODEJointGroup_newJointGroupProtoWithWorld(IOSTATE, self));
return self;
}
示例7: Command_new
T Command_new(const char *path, const char *arg0, ...) {
T C;
if (! File_exist(path))
THROW(AssertException, "File '%s' does not exist", path ? path : "null");
NEW(C);
C->env = List_new();
C->args = List_new();
List_append(C->env, Str_dup(Command_Path));
va_list ap;
va_start(ap, arg0);
buildArgs(C, path, arg0, ap);
va_end(ap);
return C;
}
示例8: main
int main(int argc, char **argv)
{
List_t l = List_new();
fprintf(stdout, "test List...\n");
int i;
for (i = 0; i < 100; i++) {
List_addFirst(l, i);
}
fprintf(stdout, "List_getFirst\n");
int r = (int) List_getFirst(l);
assert(r == 99);
fprintf(stdout, "List_getIndexOf\n");
for (i = 0; i < 100; i++) {
r = (int) List_getIndexOf(l, i);
assert(r == (99 - i));
}
fprintf(stdout, "List_addLast\n");
List_addLast(l, 200);
r = (int) List_getIndexOf(l, 100);
assert(r == 200);
fprintf(stdout, "List_size\n");
r = List_size(l);
assert(r == 101);
fprintf(stdout, "List_isEmpty\n");
r = List_isEmpty(l);
assert(r == 0);
List_t l2 = List_new();
r = List_isEmpty(l2);
assert(r == 1);
fprintf(stdout, "List_remove\n");
for (i = 0; i < 100; i++) {
r = (int) List_removeFirst(l);
assert(r == (99 - i));
}
r = (int) List_removeFirst(l);
assert(r == 200);
r = List_isEmpty(l);
assert(r == 1);
return 0;
}
示例9: RCG_node_new
RCG_node * RCG_node_new(void)
{
RCG_node *node;
node = (RCG_node *) tman_malloc(sizeof(RCG_node));
memset(node, '\0', sizeof(RCG_node));
node->selection_predicates_list = List_new();
node->join_predicates_list = List_new();
node->already_inserted = 0;
node->decorated_selection_predicate = NULL;
node->type = RCG_NODE_TYPE;
return node;
}
示例10: Context_intersect_clip_rect
//Update the clipping rectangles to only include those areas within both the
//existing clipping region AND the passed Rect
void Context_intersect_clip_rect(Context* context, Rect* rect) {
int i;
List* output_rects;
Rect* current_rect;
Rect* intersect_rect;
context->clipping_on = 1;
if(!(output_rects = List_new()))
return;
for(i = 0; i < context->clip_rects->count; i++) {
current_rect = (Rect*)List_get_at(context->clip_rects, i);
intersect_rect = Rect_intersect(current_rect, rect);
if(intersect_rect)
List_add(output_rects, (Object*)intersect_rect);
}
//Delete the original rectangle list
Object_delete((Object*)context->clip_rects);
//And re-point it to the new one we built above
context->clip_rects = output_rects;
//Free the input rect
Object_delete((Object*)rect);
}
示例11: adminInterfaces
static void adminInterfaces(Dict* args,
void* vcontext,
String* txid,
struct Allocator* alloc)
{
struct Context* context = Identity_check((struct Context*)vcontext);
int64_t* page = Dict_getIntC(args, "page");
int i = (page) ? *page * ENTRIES_PER_PAGE : 0;
int count = InterfaceController_ifaceCount(context->ic);
//int count = InterfaceController_getIface(context->ic, alloc, &stats);
List* list = List_new(alloc);
for (int counter = 0; i < count && counter++ < ENTRIES_PER_PAGE; i++) {
struct InterfaceController_Iface* iface = InterfaceController_getIface(context->ic, i);
Dict* d = Dict_new(alloc);
Dict_putIntC(d, "ifNum", iface->ifNum, alloc);
Dict_putStringC(d, "name", iface->name, alloc);
char* bs = InterfaceController_beaconStateString(iface->beaconState);
Dict_putStringCC(d, "beaconState", bs, alloc);
List_addDict(list, d, alloc);
}
Dict* resp = Dict_new(alloc);
Dict_putListC(resp, "ifaces", list, alloc);
Dict_putIntC(resp, "total", count, alloc);
if (i < count) { Dict_putIntC(resp, "more", 1, alloc); }
Admin_sendMessage(resp, txid, context->admin);
}
示例12: searchResponse
static void searchResponse(struct RouterModule_Promise* promise,
uint32_t lag,
struct Address* from,
Dict* responseDict)
{
struct Search* search = Identity_check((struct Search*) promise->userData);
struct Allocator* alloc = Allocator_child(search->alloc);
Dict* resp = Dict_new(alloc);
if (!from) {
Dict_putStringCC(resp, "error", "none", alloc);
Dict_putIntC(resp, "complete", 1, alloc);
Admin_sendMessage(resp, search->txid, search->ctx->admin);
Allocator_free(alloc);
return;
}
String* fromStr = Address_toString(from, alloc);
Dict_putStringC(resp, "from", fromStr, alloc);
Dict_putIntC(resp, "ms", lag, alloc);
struct Address_List* addrs = ReplySerializer_parse(from, responseDict, NULL, true, alloc);
List* nodes = List_new(alloc);
for (int i = 0; addrs && i < addrs->length; i++) {
String* addr = Address_toString(&addrs->elems[i], alloc);
List_addString(nodes, addr, alloc);
}
Dict_putListC(resp, "nodes", nodes, alloc);
Admin_sendMessage(resp, search->txid, search->ctx->admin);
}
示例13: io_calloc
Levels *Levels_new(IoMessage *msg)
{
Levels *self = io_calloc(1, sizeof(Levels));
IoState *state = IoObject_state(msg);
IoSymbol *operatorTableSymbol = IoState_symbolWithCString_(state, "OperatorTable");
// Be ultra flexable, and try to use the first message's operator table.
IoObject *opTable = IoObject_rawGetSlot_(msg, operatorTableSymbol);
// Otherwise, use Core OperatorTable, and if that doesn't exist, create it.
if (opTable == NULL)
{
// There is a chance the message didn't have it, but the core did---due
// to the Core not being part of the message's protos. Use Core
// Message's OperatorTable
opTable = IoObject_rawGetSlot_(state->core, operatorTableSymbol);
// If Core doesn't have an OperatorTable, then create it.
if (opTable == NULL)
{
opTable = IoObject_new(state);
IoObject_setSlot_to_(state->core, operatorTableSymbol, opTable);
IoObject_setSlot_to_(opTable, IoState_symbolWithCString_(state, "precedenceLevelCount"), IoState_numberWithDouble_(state, IO_OP_MAX_LEVEL));
}
}
self->operatorTable = getOpTable(opTable, "operators", IoState_createOperatorTable);
self->assignOperatorTable = getOpTable(opTable, "assignOperators", IoState_createAssignOperatorTable);
self->stack = List_new();
Levels_reset(self);
return self;
}
示例14: Section_new
Section* Section_new(double x, double y, double z,
double width, double height, double length, int enemies) {
Section* inst = (Section*) malloc(sizeof(Section));
int i;
Vector spawn;
double spacing;
inst->pos[0] = x, inst->pos[1] = y, inst->pos[2] = z;
inst->size[0] = width, inst->size[1] = height, inst->size[2] = length;
inst->entities = List_new();
for(i = 0, spacing = 0; i < enemies; ++i) {
spawn[0] = randomInterval(x, x + width - Enemy_DEF_SIZE[0]);
spawn[1] = randomInterval(y, y + height - Enemy_DEF_SIZE[1]);
spawn[2] = randomInterval(z + spacing, z + length);
List_pushBack(inst->entities, Enemy_new(
spawn[0], spawn[1], spawn[2], random(),
random() * 5 + 1, 800));
spacing += Enemy_DEF_SIZE[2] + length/enemies;
}
return inst;
}
示例15: Levels_new
IoMessage *IoMessage_opShuffle(IoMessage *self, IoObject *locals, IoMessage *m)
{
Levels *levels = Levels_new(self);
List *expressions = List_new();
List_push_(expressions, self);
while (List_size(expressions) >= 1)
{
IoMessage *n = List_pop(expressions);
do
{
Levels_attach(levels, n, expressions);
List_appendSeq_(expressions, DATA(n)->args);
} while ((n = DATA(n)->next));
Levels_nextMessage(levels);
}
List_free(expressions);
Levels_free(levels);
return self;
}