Posts

arraylist - Java List, Counting non-zero attributes of Object, by group of 3 -

i have arraylist<fileline> , inside fileline function public double getvalue() { ... doing stuff ... return value; } what i'm trying return count of non-zero getvalue() of group of 3 filelines. let's have list<fileline> filelines of filelines.size() = 12 , respective getvalue() 0,0,0, 0,1,2, 0,3,0, 4,5,5 result i'd 3, valid expect first group. if group of 1 fileline filter , count : long resultcount = filelines.stream().filter(x -> x.getvalue() > 0).count(); , fact it's group of 3 causing me problem. is best approach split list multiple 3 elements sublists or more elegant way? you can group 3 mapping range of indices sublists this: list<fileline> filtered = intstream.range(0, list.size()/3) .maptoobj(n -> list.sublist(n*3, n*3+3)) .filter(sublist -> sublist.stream().anymatch(fl -> fl.getvalue() != 0.0)) .flatmap(list::stream) .collect(collectors.tolist()); i assume...

Why excel rounded but still shows more than 2 decimal points -

i have set of numbers rounded of 2. when sum range, ended on cell shows 762,078.31. copied cell , paste value , shows 762078.31. increased decimal , still shows 762078.3100. on 'formula bar' shows 762078.309999999. i show calculations here there ~359 rows. it's simple formula used follows; =round(q2*s2,2) , =sum(y2:y359). idea why happens, let me know. thanks. not sure why it's happening, can edit sum cell round well: =round(sum(y2:y359),2)

mysql - how to design mvc entity models -

its pain me design models. way iam progressing is: find out data involved create database data create entity models data manually ie without table2class conversion the reason told without table2class conversion is: need understand how on mysql/manually. beginner , feel hard each time put hand on area. consider example of saving rating employee , company. employee can rate self , several employees can rate company. database become: employeerating : id | employee_id | tag_id | rating companyrating : id | company_id | employee_id | tag_id | rating how design models scenario. don't it. below model wanted. [table("employee")] public class employee { [key] public int id { get; set; } ... public list<rating> ratings { get; set; } } [table("company")] public class company { [key] public int id { get; set; } ... list of list of rating can seperate each employee should come here } how design mode...

objective c - Multiple UIAlertControllers in iOS -

in app there scenarios multiple alerts come. in ios8 uialertview turned uialertcontroller, not able show multiple alerts can not present 2 or more controllers @ same time. how can achieve using uialertcontroller? here method show multiple alertcontrollers : uialertcontroller *av = [uialertcontroller alertcontrollerwithtitle:title message:msg preferredstyle:uialertcontrollerstylealert]; uialertaction *cancelaction = [uialertaction actionwithtitle:kalertok style:uialertactionstylecancel handler:^(uialertaction *action) { }]; [av addaction:cancelaction]; uiwindow *alertwindow = [[uiwindow alloc]initwithframe:[uiscreen mainscreen].bounds]; alertwindow.rootviewcontroller = [[uiviewcontroller alloc]init]; alertwindow.windowlevel = ui...

Regex: negative match on group of characters? -

i want create regular expression match strings starting 0205052i0 , next 2 characters not bb. so want match: 0205052i0aaaaaa 0205052i0acaaaa 0205052i0bcabaa but not match: 0205052i0bbaa how can pcre regular expressions? i've been trying $0205052i0^(bb) on https://regex101.com/ doesn't work. you can use negative ahead : "0205052i0(?!bb).*" see demo https://regex101.com/r/mo6uv4/1 also note have putted anchors @ wrong position. if want use anchor can use following regex : "^0205052i0(?!bb).*$"

javascript - Iterate through IEnumerable Model without loop - ASP.NET-MVC5 -

Image
i have typed ienumerable of 2 records passing view controller. have maximum 2 records. need print these 2 record in separate form i.e. html beginform. my question how can print ienumerable model data without using @for or @foreach loop??? can use kind of index read object in model , data based on index??? get data record public list<emergencycontact> getemergencycontactbystudentid(int _studentid) { try { using (var _uow = new studentprofile_unitofwork()) { var _record = (from _emergencycontact in _uow.emergencycontact_repository.getall() join _student in _uow.student_repository.getall() on _emergencycontact.studentid equals _student.studentid _emergencycontact.studentid == _studentid select _emergencycontact).tolist(); return _record; } } catch { return null; } } contr...

html - Why does the scrollbar not work in IE? -

i have created scrollbar , works fine in google chrome , firefox not in ie. have feeling has line-height property. my code: html: <div id="scrollbar"><br /></div> css: #scrollbar { margin-top: 10px; height: 220px; float: right; overflow-y: scroll; line-height: 403px; } here jsfiddle . anyway work in ie? change <br/> &nbsp; . ie picks non-breaking space bit better <br> tag. http://jsfiddle.net/s9sycey1/3/