uint64_t select(uint64_t i, bool b = true){ return b ? select1(i) : select0(i); }
size_t BitSequence::selectPrev0(const size_t i) const { size_t v = rank0(i); if (v < 2) return (size_t) -1; return select0(v - 1); }
function main(in mode0) { //WHATSNEW returns in ANS ANS=""; var mode=mode0; var keywords = "MEDIA" _VM_ "JOBS" _VM_ "FINANCE" _VM_ "TIMESHEETS" _VM_ "TECHNICAL" _VM_ "USER INTERFACE"; var nkeywords = keywords.count(VM) + 1; if (not(openfile("CHANGELOG", changelog))) { call fsmsg(); return 0; } if (not(openfile("DICT_CHANGELOG", DICT))) { call fsmsg(); return 0; } if (mode.a(1) == "SELECTANDLIST") { //call changelog.subs('SELECT':fm:data) gosub select0(mode); if (not LISTACTIVE) { call mssg("Error: No records found"); return 0; } //call changelog.subs('LIST':fm:data) gosub list(mode); //returns outputfilename in ANS } else if (mode.a(1) == "WHATSNEW") { var menucodes = mode.a(2); mode = mode.a(1); ANS = ""; var users; if (not(users.open("USERS", ""))) { return 0; } var userrec; if (userrec.read(users, USERNAME)) { //backward compatible ... can be deleted after all upgraded //leave in case reloading ancient data if (not userrec.a(17)) { var changelogkey = "USER*" ^ USERNAME; if (changelog.read(DEFINITIONS, changelogkey)) { userrec.r(17, changelog.a(8)); (userrec.a(17)).writev(users, USERNAME, 17); var("").writev(DEFINITIONS, changelogkey, 8); } } //mode<2>=changelog<7> mode.r(3, userrec.a(17)); //fix a problem where people were missing most changes //due to sv being represented as : eg user:support:technical if (mode.a(3) and mode.a(3) < 14773) { mode.r(3, 14153); } }else{ //show everything the first time they logon //mode<3>=iconv('1/1/2004','D/E') //show nothing the very first time they logon ANS = ""; return 0; } //get last upgradedate var temp = var(".\\GENERAL\\VERSION.DAT").xlate("DOS", 1, "X"); var lastupgradedatetime = (temp.trim().field(" ", 2, 999)).iconv("D"); lastupgradedatetime ^= "." ^ ((temp.trim().field(" ", 1)).iconv("MT")).oconv("R(0)#5"); //nothing to see if seen after lastupgradedate if (mode.a(3) >= lastupgradedatetime) { ANS = ""; return 0; } lastupgradedatetime.writev(users, USERNAME, 17); //build preferences from menus if not specified if (not mode.a(2)) { //tt=capitalise(menucodes) //swap 'Support' with 'Technical' in tt //mode<2>=tt if (menucodes.index("FINANCE", 1)) { mode.r(2, -1, "Finance"); } if (menucodes.index("MEDIA", 1)) { mode.r(2, -1, "Media"); } if (menucodes.index("JOBS", 1)) { mode.r(2, -1, "Jobs"); } if (menucodes.index("TIMESHEETS", 1)) { mode.r(2, -1, "Timesheets"); } if (menucodes.index("SUPPORT", 1)) { mode.r(2, -1, "Technical"); } //everybody gets User Interface changes mode.r(2, -1, "User Interface"); //if no preferences then no whats new //if mode<2> else // @ans='' // return 0 // end } //indicate need to select whats new preferences (by numeric whatsnew) //if mode<2> else // if lastupgradedate else lastupgradedate='0' // @ans=lastupgradedate // return 0 // end //find and new items else quit gosub select(mode); if (not LISTACTIVE) { ANS = ""; return 0; } //make a suitable output filename based on the responsefilename temp = PRIORITYINT.a(100); temp.splicer(-1, 1, "HTM"); SYSTEM.r(2, temp); //get new items in new filename and return the filename in @ans gosub list(mode); ANS = SYSTEM.a(2); } else if (mode == "GETUPGRADEDATES") { gosub getupgradedates(); } else if (mode.a(1) == "SELECT") { gosub select0(mode); } else if (mode.a(1) == "LIST") { gosub list(mode); } return 0; }
size_t BitSequence::selectNext0(const size_t i) const { return select0((i == 0 ? 0 : rank0(i - 1)) + 1); }
/** * @brief Returns the position of the x-th occurrence of `b` * * @param[in] x Rank number of b-bits * @param[in] b Boolean value that indicates bit type.(true = 1, false = 0) * * @return Index of x-th 0 */ FORCE_INLINE uint64_t select(uint64_t x, bool b = true) const { return b ? select1(x) : select0(x); }