/* Generate a file notification event. */ static void kqueue_generate_event (Lisp_Object watch_object, Lisp_Object actions, Lisp_Object file, Lisp_Object file1) { Lisp_Object flags, action, entry; struct input_event event; /* Check, whether all actions shall be monitored. */ flags = Fnth (make_number (2), watch_object); action = actions; do { if (NILP (action)) break; entry = XCAR (action); if (NILP (Fmember (entry, flags))) { action = XCDR (action); actions = Fdelq (entry, actions); } else action = XCDR (action); } while (1); /* Store it into the input event queue. */ if (! NILP (actions)) { EVENT_INIT (event); event.kind = FILE_NOTIFY_EVENT; event.frame_or_window = Qnil; event.arg = list2 (Fcons (XCAR (watch_object), Fcons (actions, NILP (file1) ? Fcons (file, Qnil) : list2 (file, file1))), Fnth (make_number (3), watch_object)); kbd_buffer_store_event (&event); } }
TEST(ContiguousContainerTest, Swap) { ContiguousContainer<Point2D, kPointAlignment> list1(kMaxPointSize); list1.allocateAndConstruct<Point2D>(1, 2); ContiguousContainer<Point2D, kPointAlignment> list2(kMaxPointSize); list2.allocateAndConstruct<Point2D>(3, 4); list2.allocateAndConstruct<Point2D>(5, 6); EXPECT_EQ(1u, list1.size()); EXPECT_EQ(1, list1[0].x); EXPECT_EQ(2, list1[0].y); EXPECT_EQ(2u, list2.size()); EXPECT_EQ(3, list2[0].x); EXPECT_EQ(4, list2[0].y); EXPECT_EQ(5, list2[1].x); EXPECT_EQ(6, list2[1].y); list2.swap(list1); EXPECT_EQ(1u, list2.size()); EXPECT_EQ(1, list2[0].x); EXPECT_EQ(2, list2[0].y); EXPECT_EQ(2u, list1.size()); EXPECT_EQ(3, list1[0].x); EXPECT_EQ(4, list1[0].y); EXPECT_EQ(5, list1[1].x); EXPECT_EQ(6, list1[1].y); }
int main() { //Testing List class and Node class from SingleLinkedList namespace SingleLinkedList::List<int> list; list.Insert(10); list.Insert(4); list.Insert(10); list.Insert(5); list.Insert(2); list.PrintList(); SingleLinkedList::List<int> list2(list); std::cout << "The copied list looks following:\n"; list2.PrintList(); list.~List(); list.PrintList(); /*SingleLinkedList::List list2; list2.Insert(10); list2.PrintList(); list2.Remove(10); list2.PrintList();*/ return 0; }
/* ======================================================================================================================= ======================================================================================================================= */ void CDialogTextures::addSounds(bool rootItems) { int i, j; idStrList list(1024); idStrList list2(1024); HTREEITEM base = m_treeTextures.InsertItem(TypeNames[SOUNDS]); for(i = 0; i < declManager->GetNumDecls( DECL_SOUND ); i++) { const idSoundShader *poo = declManager->SoundByIndex(i, false); list.AddUnique( poo->GetFileName() ); } idStrListSortPaths( list ); for (i = 0; i < list.Num(); i++) { HTREEITEM child = m_treeTextures.InsertItem(list[i], base); m_treeTextures.SetItemData(child, SOUNDPARENT); m_treeTextures.SetItemImage(child, 0, 1); list2.Clear(); for (j = 0; j < declManager->GetNumDecls( DECL_SOUND ); j++) { const idSoundShader *poo = declManager->SoundByIndex(j, false); if ( idStr::Icmp( list[i], poo->GetFileName() ) == 0 ) { list2.Append( poo->GetName() ); } } idStrListSortPaths( list2 ); for (j = 0; j < list2.Num(); j++) { HTREEITEM child2 = m_treeTextures.InsertItem( list2[j], child ); m_treeTextures.SetItemData(child2, SOUNDS); m_treeTextures.SetItemImage(child2, 2, 2); } } }
TEST(ContiguousContainerTest, AppendByMovingDoesNotDestruct) { // GMock mock objects (e.g. MockDestructible) aren't guaranteed to be safe // to memcpy (which is required for appendByMoving). class DestructionNotifier { public: DestructionNotifier(bool* flag = nullptr) : m_flag(flag) {} ~DestructionNotifier() { if (m_flag) *m_flag = true; } private: bool* m_flag; }; bool destroyed = false; ContiguousContainer<DestructionNotifier> list1(sizeof(DestructionNotifier)); list1.allocateAndConstruct<DestructionNotifier>(&destroyed); { // Make sure destructor isn't called during appendByMoving. ContiguousContainer<DestructionNotifier> list2(sizeof(DestructionNotifier)); list2.appendByMoving(list1.last(), sizeof(DestructionNotifier)); EXPECT_FALSE(destroyed); } // But it should be destroyed when list2 is. EXPECT_TRUE(destroyed); }
TEST(AtomicIntrusiveLinkedList, Move) { TestIntrusiveObject a(1), b(2); TestIntrusiveObject::List list1; EXPECT_TRUE(list1.insertHead(&a)); EXPECT_FALSE(list1.insertHead(&b)); EXPECT_FALSE(list1.empty()); TestIntrusiveObject::List list2(std::move(list1)); EXPECT_TRUE(list1.empty()); EXPECT_FALSE(list2.empty()); TestIntrusiveObject::List list3; EXPECT_TRUE(list3.empty()); list3 = std::move(list2); EXPECT_TRUE(list2.empty()); EXPECT_FALSE(list3.empty()); size_t id = 0; list3.sweep([&](TestIntrusiveObject* obj) mutable { ++id; EXPECT_EQ(id, obj->id()); }); }
INLINE_FUN SEXP lang3(SEXP s, SEXP t, SEXP u) { PROTECT(s); s = LCONS(s, list2(t, u)); UNPROTECT(1); return s; }
Value Bignum::type_of() const { if (mpz_sgn(_z) > 0) return list2(S_integer, make_integer(MOST_POSITIVE_FIXNUM + 1)); else return S_bignum; }
void CPreviewDlg::AddSkins( bool rootItems ) { idStrList list(1024); idStrList list2(1024); idStr str; int count = declManager->GetNumDecls( DECL_SKIN ); if (count > 0) { for (int i = 0; i < count; i++) { const idDeclSkin *skin = declManager->SkinByIndex(i); if (!rootItems) { if (strchr(skin->GetName(), '/') == NULL && strchr(skin->GetName(), '\\') == NULL) { continue; } } if ( data.Length() ) { for ( int j = 0; j < skin->GetNumModelAssociations(); j++ ){ str = skin->GetAssociatedModel( j ); str.ToLower(); if ( data.Cmp(str) == 0 ) { list.Append(skin->GetName()); } } } list2.Append(skin->GetName()); } list.Sort(); list2.Sort(); AddStrList( "Matching Skins", list, SKINS ); AddStrList( "Skins", list2, SKINS ); } }
TEST(Stack_dg_ListCircular, creation_dg_ListCircular) { DgList list; for (int i = 0; i < 17; ++i) { list.push_back(i); } auto it = list.head(); for (int i = 0; i < 8; ++i) { ++it; } for (int i = 0; i < 3; ++i) { it = list.erase(it); } it++; it++; list.insert(it, -1); DgList list2(list); DgList list3 = list; //list.Print(); //list2.Print(); //list3.Print(); }
void LinkedListTest::moveList() { Item* item1 = new Item; Item* item2 = new Item; LinkedList list; list.insert(item1); list.insert(item2); /* Move constructor */ LinkedList list2(std::move(list)); CORRADE_VERIFY(list.first() == nullptr); CORRADE_VERIFY(list.last() == nullptr); CORRADE_VERIFY(list2.first() == item1); CORRADE_VERIFY(list2.last() == item2); CORRADE_VERIFY(item1->list() == &list2); CORRADE_VERIFY(item2->list() == &list2); CORRADE_COMPARE(Item::count, 2); LinkedList list3; list3.insert(new Item); /* Move assignment */ list3 = std::move(list2); CORRADE_VERIFY(list2.first() == nullptr); CORRADE_VERIFY(list2.last() == nullptr); CORRADE_VERIFY(list3.first() == item1); CORRADE_VERIFY(list3.last() == item2); CORRADE_VERIFY(item1->list() == &list3); CORRADE_VERIFY(item2->list() == &list3); list3.clear(); CORRADE_COMPARE(Item::count, 0); }
static Lisp_Object inotifyevent_to_event (Lisp_Object watch, struct inotify_event const *ev) { Lisp_Object name; uint32_t mask; CONS_TO_INTEGER (Fnth (make_number (3), watch), uint32_t, mask); if (! (mask & ev->mask)) return Qnil; if (ev->len > 0) { size_t const len = strlen (ev->name); name = make_unibyte_string (ev->name, min (len, ev->len)); name = DECODE_FILE (name); } else name = XCAR (XCDR (watch)); return list2 (list4 (Fcons (INTEGER_TO_CONS (ev->wd), XCAR (watch)), mask_to_aspects (ev->mask), name, INTEGER_TO_CONS (ev->cookie)), Fnth (make_number (2), watch)); }
Value table1(Value k, Value v) { Value table = list2(k, v); table.object->logical_type = TABLE_TYPE; table.object->layout = TABLE_LAYOUT_UNINDEXED_LIST; return table; }
static void set_frame_size (EmacsFrame ew) { /* The widget hierarchy is argv[0] emacsShell pane Frame-NAME ApplicationShell EmacsShell Paned EmacsFrame We accept geometry specs in this order: *Frame-NAME.geometry *EmacsFrame.geometry Emacs.geometry Other possibilities for widget hierarchies might be argv[0] frame pane Frame-NAME ApplicationShell EmacsShell Paned EmacsFrame or argv[0] Frame-NAME pane Frame-NAME ApplicationShell EmacsShell Paned EmacsFrame or argv[0] Frame-NAME pane emacsTextPane ApplicationShell EmacsFrame Paned EmacsTextPane With the current setup, the text-display-area is the part which is an emacs "frame", since that's the only part managed by emacs proper (the menubar and the parent of the menubar and all that sort of thing are managed by lwlib.) The EmacsShell widget is simply a replacement for the Shell widget which is able to deal with using an externally-supplied window instead of always creating its own. It is not actually emacs specific, and should possibly have class "Shell" instead of "EmacsShell" to simplify the resources. */ /* Hairily merged geometry */ struct frame *f = ew->emacs_frame.frame; int w = FRAME_COLS (f); int h = FRAME_LINES (f); Widget wmshell = get_wm_shell ((Widget) ew); Dimension pixel_width, pixel_height; /* Each Emacs shell is now independent and top-level. */ if (! XtIsSubclass (wmshell, shellWidgetClass)) emacs_abort (); char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height); ew->core.width = (frame_resize_pixelwise ? FRAME_PIXEL_WIDTH (f) : pixel_width); ew->core.height = (frame_resize_pixelwise ? FRAME_PIXEL_HEIGHT (f) : pixel_height); frame_size_history_add (f, Qset_frame_size, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), list2 (make_number (ew->core.width), make_number (ew->core.height))); }
static Lisp_Object x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, int local_request, struct mac_display_info *dpyinfo) { Lisp_Object local_value; Lisp_Object handler_fn, value, type, check; if (!x_selection_owner_p (selection_symbol, dpyinfo)) return Qnil; local_value = LOCAL_SELECTION (selection_symbol, dpyinfo); /* TIMESTAMP is a special case. */ if (EQ (target_type, QTIMESTAMP)) { handler_fn = Qnil; value = XCAR (XCDR (XCDR (local_value))); } else { /* Don't allow a quit within the converter. When the user types C-g, he would be surprised if by luck it came during a converter. */ ptrdiff_t count = SPECPDL_INDEX (); specbind (Qinhibit_quit, Qt); CHECK_SYMBOL (target_type); handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist)); /* gcpro is not needed here since nothing but HANDLER_FN is live, and that ought to be a symbol. */ if (!NILP (handler_fn)) value = call3 (handler_fn, selection_symbol, (local_request ? Qnil : target_type), XCAR (XCDR (local_value))); else value = Qnil; unbind_to (count, Qnil); } if (local_request) return value; /* Make sure this value is of a type that we could transmit to another application. */ type = target_type; check = value; if (CONSP (value) && SYMBOLP (XCAR (value))) type = XCAR (value), check = XCDR (value); if (NILP (value) || mac_valid_selection_value_p (check, type)) return value; signal_error ("Invalid data returned by selection-conversion function", list2 (handler_fn, value)); }
Layout * Condition::get_layout_for_class() { static Layout * layout; if (layout == NULL) layout = new Layout(the_class(C_condition), list2(S_format_control, S_format_arguments), NIL); return layout; }
int retool_dfa( int argc, char* argv[] ) { atom_t dv = nil; atom_t iv; atom_t d; int i, p; if( argc < 3 ) { (void)fprintf( stderr, "usage: dfa regex alphabet\n" ); return 1; } atom_t atom = re_posix_parse( argv[1] ); char *x = argv[2]; (void)printf( "\n" ); (void)printf( " " ); while( *x ) { (void)printf( " %c", *x ); ++x; } (void)printf( "\n\n" ); dv = list2( nil, atom ); iv = cdr(dv); for( i = 1 ; iv ; ++i ) { (void)printf( "% 4d: ", i ); x = argv[2]; while( *x ) { d = brz_deriv( atom, *x ); p = position( d, dv ); if( p < 0 ) dv = append( dv, d ); p = position( d, dv ); if( p ) { (void)printf( "% 4d", p ); } else { (void)printf( " ." ); } ++x; } (void)printf( " " ); re_posix_dump( atom ); iv = cdr(iv); if( !iv ) break; atom = car(iv); } (void)printf( "\n" ); return !truep( atom ); }
int main(int argc, char *argv[]) { std::vector<double> vdouble{1,2,3,4,5,6,7,8,9}; std::list<int> list1(vdouble.cbegin(),vdouble.cend()); print_list(list1,"vector double initialize list<int>"); std::vector<int> vint{4,5,6,8,9,10}; std::list<int> list2(vint.cbegin(),vint.cend()); print_list(list2,"vector int initialize list<int>"); }
void TestVariant::testQList() { QVariantList list; list.append("teststring"); list.append(123); Variant var(list); QVariantList list2(var.toQList()); QCOMPARE(list, list2); }
TEST(ContiguousContainerTest, AppendByMovingReturnsMovedPointer) { ContiguousContainer<Point2D, kPointAlignment> list1(kMaxPointSize); ContiguousContainer<Point2D, kPointAlignment> list2(kMaxPointSize); Point2D& point = list1.allocateAndConstruct<Point2D>(); Point2D& movedPoint1 = list2.appendByMoving(point, sizeof(Point2D)); EXPECT_EQ(&movedPoint1, &list2.last()); Point2D& movedPoint2 = list1.appendByMoving(movedPoint1, sizeof(Point2D)); EXPECT_EQ(&movedPoint2, &list1.last()); EXPECT_NE(&movedPoint1, &movedPoint2); }
void init_coll_functions(void) { define_generic_function("element", list2(obj_CollClass, obj_ObjectClass), false, list1(symbol("default")), false, list1(obj_ObjectClass), obj_False); define_generic_function("element-setter", list3(obj_ObjectClass, obj_CollClass, obj_ObjectClass), false, obj_False, false, list1(obj_ObjectClass), obj_False); define_generic_function("size", list1(obj_ObjectClass), false, obj_False, false, obj_Nil, obj_ObjectClass); }
void test1() { SeqList list1; list1.PushBack(1); list1.PushBack(2); list1.PushBack(3); list1.PushBack(4); list1.PushFront(0); list1.PopBack(); list1.PopFront(); SeqList list2(list1); cout << list1 << endl; cout << list2 << endl; }
static emacs_value module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, emacs_subr subr, const char *documentation, void *data) { MODULE_FUNCTION_BEGIN (module_nil); if (! (0 <= min_arity && (max_arity < 0 ? max_arity == emacs_variadic_function : min_arity <= max_arity))) xsignal2 (Qinvalid_arity, make_number (min_arity), make_number (max_arity)); /* FIXME: This should be freed when envobj is GC'd. */ struct module_fun_env *envptr = xmalloc (sizeof *envptr); envptr->min_arity = min_arity; envptr->max_arity = max_arity; envptr->subr = subr; envptr->data = data; Lisp_Object envobj = make_save_ptr (envptr); Lisp_Object doc = (documentation ? code_convert_string_norecord (build_unibyte_string (documentation), Qutf_8, false) : Qnil); /* FIXME: Use a bytecompiled object, or even better a subr. */ Lisp_Object ret = list4 (Qlambda, list2 (Qand_rest, Qargs), doc, list4 (Qapply, list2 (Qfunction, Qinternal__module_call), envobj, Qargs)); return lisp_to_value (ret); }
TEST(ContiguousContainerTest, AppendByMovingReplacesSourceWithNewElement) { ContiguousContainer<Point2D, kPointAlignment> list1(kMaxPointSize); ContiguousContainer<Point2D, kPointAlignment> list2(kMaxPointSize); list1.allocateAndConstruct<Point2D>(1, 2); EXPECT_EQ(1, list1.first().x); EXPECT_EQ(2, list1.first().y); list2.appendByMoving(list1.first(), sizeof(Point2D)); EXPECT_EQ(0, list1.first().x); EXPECT_EQ(0, list1.first().y); EXPECT_EQ(1, list2.first().x); EXPECT_EQ(2, list2.first().y); EXPECT_EQ(1u, list1.size()); EXPECT_EQ(1u, list2.size()); }
void TestCopyConstructor1() { std::cout << "TestCopyConstructor1..." << std::endl; int size = 10; CS170::List list1; for (int i = 1; i <= size; i++) list1.push_front(i * 3); std::cout << "List 1: "; std::cout << list1; CS170::List list2(list1); std::cout << "List 2: "; std::cout << list2; std::cout << std::endl; }
int main() { List list; list.add_back(1); list.add_back(2); list.add_back(3); list.add_front(4); list.print(); list.remove(5); list.remove(3); list.print(); List list2(list); list2.print(); list2.add(1, 5); list.print(); list2.print(); return 0; }
bool BackendIntegrationTests::contentsEqual( const TaskList& listref1, const TaskList& listref2 ) { TaskList list1( listref1 ); TaskList list2( listref2 ); for ( int i = 0; i < list1.size(); ++i ) { for ( int j = 0; j < list2.size(); ++j ) { if ( list2[j] == list1[i] ) { list2.removeAt( j ); } } } return list2.isEmpty(); }
// ### make-logical-pathname namestring => logical-pathname Value SYS_make_logical_pathname(Value arg) { AbstractString * s = check_string(arg); AbstractString * h = get_host_string(s); if (h != NULL) { if (h->length() == 0) { // "The null string, "", is not a valid value for any component of a // logical pathname." 19.3.2.2 return signal_lisp_error("Invalid logical host name: \"\""); } if (LOGICAL_PATHNAME_TRANSLATION_TABLE->get(make_value(h)) != NULL_VALUE) return make_value(new LogicalPathname(h, s->substring(s->index_of(':') + 1))); } return signal_lisp_error(new TypeError("Logical namestring does not specify a valid host", arg, list2(S_satisfies, S_logical_namestring_p))); }
static LVAL newmatrix P2C(unsigned, r, unsigned, c) { LVAL rows, cols, dim, result; xlstkcheck(3); xlsave(rows); xlsave(cols); xlsave(dim); rows = cvfixnum((FIXTYPE) r); cols = cvfixnum((FIXTYPE) c); dim = list2(rows, cols); result = mkarray(dim, NIL, NIL, s_true); xlpopn(3); return(result); }
/* void GetAppList(const char *signature, BList *teamIDList) const @case 3 teamIDList is not NULL and not empty, signature is not NULL and app(s) with this signature is (are) running @results Should append the team IDs of all running apps with the supplied signature to teamIDList. */ void GetAppListTester::GetAppListTestB3() { const char *signature = "application/x-vnd.obos-app-run-testapp1"; // create a list with some dummy entries BList list; list.AddItem((void*)-7); list.AddItem((void*)-42); // get a list of running applications for reference BRoster roster; BList list1(list); roster.GetAppList(signature, &list1); check_list(list1, list); // run some apps AppRunner runner1(true); AppRunner runner2(true); AppRunner runner3(true); CHK(runner1.Run("AppRunTestApp1") == B_OK); CHK(runner2.Run("AppRunTestApp2") == B_OK); CHK(runner3.Run("BMessengerTestApp1") == B_OK); BList expectedApps; expectedApps.AddItem((void*)runner1.Team()); expectedApps.AddItem((void*)runner2.Team()); // get a new app list and check it BList list2(list); roster.GetAppList(signature, &list2); check_list(list2, list, expectedApps); // quit app 1 runner1.WaitFor(true); expectedApps.RemoveItem((void*)runner1.Team()); BList list3(list); roster.GetAppList(signature, &list3); check_list(list3, list, expectedApps); // quit app 2 runner2.WaitFor(true); expectedApps.RemoveItem((void*)runner2.Team()); BList list4(list); roster.GetAppList(signature, &list4); check_list(list4, list, expectedApps); // quit app 3 runner3.WaitFor(true); BList list5(list); roster.GetAppList(signature, &list5); check_list(list5, list, expectedApps); }