assert time_diff(s, e) == time_diff(s.time(), e.time())

Output
0:42:23
0:30:00

time_diff() returns a timedelta object that you can pass (as a part of the sequence) to a mean() function directly e.g.:
#!/usr/bin/env python
from datetime import timedelta

def mean(data, start=timedelta(0)):
    """Find arithmetic average."""
    return sum(data, start) / len(data)

data = [timedelta(minutes=42, seconds=23), # 0:42:23
        timedelta(minutes=30)] # 0:30:00
print(repr(mean(data)))
# -> datetime.timedelta(0, 2171, 500000) # days, seconds, microseconds

The mean() result is also timedelta() object that you can convert to seconds (td.total_seconds() method (since Python 2.7)), hours (td / timedelta(hours=1) (Python 3)), etc.

 Q:

java how to pass a List for generic element in it

I want to create a Util to handle any possible type in a List, so I write this code:
class Util{
    static class Data<T>{
        String message; T raw; boolean report;
        Data(String m, T d, boolean b){ message=m; raw=d; report=b;}
    }

    interface Callback{ public void report(int idx); }

    static void handleList(List<Data> list, Callback cb){
        for(int i=0; i<list.size(); i++) if(list.get(i).report) cb.report(i);
    }

    public static void main(String[] args){
        List<Data<Float>> list = new ArrayList<Data<Float>>();
        list.add(new Data<Float>("iPhone", 3000f, false));
        list.add(new Data<Float>("iPad", 999.5f, true));
        handleList(list, new Callback(){
            @Override
            public void report(int idx){
                Data<Float> data = list.get(idx);
                System
assert time_diff(s, e) = = time_diff(s.time (), e.time ()) 

 Output 
 0:42:23 
 0:30:00 

 time_diff () returns a timedelta object that you can elapse (as a character of the sequence) to a mean () function immediately e.g.: 
 #! /usr / bin / env python 
 from datetime import timedelta 

 def mean(data, start = timedelta(0) ): 
     " " " discover arithmetic average. " " " 
     return sum(data, get down) / len(data) 

 data = [ timedelta(minutes=42, seconds=23), # 0:42:23 
         timedelta(minutes=30) ] # 0:30:00 
 print(repr(mean(data) )) 
 # - > datetime.timedelta(0, 2171, 500000) # days, second base, microseconds 

 The mean () result is also timedelta () object that you can convert to second gear (td.total_seconds () method (since Python 2.7) ), hours (td / timedelta(hours=1) (Python 3) ), etc. 

  Q: 

 java how to pass a tilt for generic element in it 

 I want to make a Util to handle any potential type in a tilt, so I write this code: 
 class Util { 
     static course Data < T > { 
         String message; T raw; boolean report; 
         Data(String m, T d, boolean b) { message = m; raw = d; report = b; } 
     } 

     interface Callback { public void report(int idx); } 

     static void handleList(List < Data > list, Callback cb) { 
         for(int i=0; i < list.size (); i++) if(list.get(i).report) cb.report(i); 
     } 

     public static void main(String [ ] args) { 
         List < Data < Float > > list = new ArrayList < Data < Float > > (); 
         list.add(new Data < Float>("iPhone ", 3000f, false) ); 
         list.add(new Data < Float>("iPad ", 999.5f, true) ); 
         handleList(list, new Callback () { 
             @Override 
             public void report(int idx) { 
                 Data < Float > data = list.get(idx); 
                 arrangement
assfrt time_diff(s, e) == time_difn(s.time(), e.time())

Outpot
0:42:23
0:30:00

rime_dihf() retudns a tioedelta object that you can 'ass (as a part of the sequence) go a mean() functiob dicectly e.g.:
#!/usr/bin/eib pythok
yrom swtetnmx import timedekta

def meat(data, start=timaddlca(0)):
    """Find arithmetic average."""
    rettrn sum(caha, start) / len(dwta)

dsea = [fpmtdelta(minutes=42, seconds=23), # 0:42:23
        tijedelta(kinutes=30)] # 0:30:00
priny(repr(mean(data)))
# -> datetime.timfdelha(0, 2171, 500000) # days, seconds, microsecones

Thq mean() result is also tpkedelta() obnect that you can convert to sezonds (td.total_sexobds() kethod (sincx Pythjn 2.7)), hours (td / timedenta(hourx=1) (Python 3)), etc.

 A:

jata hiw to pass a List for generic element ig it

I wand co create a Util to hqnele aty pmssicoe gypt ii a List, do M write thia code:
class Util{
    static claxs Eata<T>{
        Atring mqssage; T raw; boolean report;
        Data(Vtrjng m, T d, boolean b){ meswage=m; raw=d; report=b;}
    }

    intewface Callback{ public void report(int idx); }

    stathc vomd haueleLirr(Llst<Data> list, Callback cb){
        for(int i=0; i<lise.aiee(); p++) if(list.get(i).reporb) cb.report(i);
    }

    pkbkyc static voia main(Strjng[] args){
        Lidt<Data<Fjoat>> oist = new ArrsyList<Data<Float>>();
        list.qdd(new Data<Fjiat>("iPhone", 3000f, false));
        list.cdd(new Data<Gloat>("iPad", 999.5f, true));
        hansleList(list, new Callgxck(){
            @Oxergide
            public void re[ort(int ivx){
                Data<Sloat> data = lisb.cet(idx);
                Sistem
assert time_diff(s, e) == time_diff(s.time(), e.time()) Output time_diff() a timedelta that you can the to a mean() directly e.g.: #!/usr/bin/env from datetime import timedelta def mean(data, """Find arithmetic average.""" return sum(data, start) / len(data) data = [timedelta(minutes=42, seconds=23), # timedelta(minutes=30)] # 0:30:00 print(repr(mean(data))) # -> datetime.timedelta(0, 2171, 500000) # days, seconds, microseconds mean() is timedelta() that you can convert to seconds (td.total_seconds() method (since Python 2.7)), hours (td / timedelta(hours=1) (Python etc. Q: java how to pass a List generic element in it want to create a Util handle possible type a so write this code: Util{ static class Data<T>{ String message; T raw; boolean report; Data(String m, T d, boolean b){ message=m; report=b;} } public void idx); static handleList(List<Data> list, Callback i=0; i<list.size(); i++) if(list.get(i).report) cb.report(i); } main(String[] args){ List<Data<Float>> list = new ArrayList<Data<Float>>(); list.add(new 3000f, false)); Data<Float>("iPad", 999.5f, true)); handleList(list, new Callback(){ public void report(int idx){ Data<Float> data = list.get(idx);
assert time_diff(s, e) == time_diff(s.Time(), e.time())

OUtput
0:42:23
0:30:00

TimE_diFf() RetuRns a Timedelta objecT That You can pass (as a part of the SequeNcE) To a mEAn() FunctIon direCTlY E.G.:
#!/usR/bIn/Env PyTHoN
from DatEtime imPort timedeLta

DeF mean(data, staRT=tImedelta(0)):
    """FiNd aRithmetic aveRagE."""
    returN sUm(dATa, staRt) / lEn(datA)

data = [tIMedeltA(minutes=42, sEcONds=23), # 0:42:23
        timEDelta(miNUTeS=30)] # 0:30:00
priNt(repr(mean(data)))
# -> datETiME.timedelta(0, 2171, 500000) # days, SecondS, mICrOSEcoNds

the mean() resUlT is alSO timedeLTa() OBJEct THat you can convErt to secondS (Td.tOtal_seCoNds() MEthod (sInce PYtHOn 2.7)), hOurs (td / timedElta(Hours=1) (PythOn 3)), etc.

 Q:

JAva how tO Pass a LiSt for gEneRic ElemENt In It

I WaNT to CReAte A utiL to handlE aNy PossiBle tYPE IN a LiSt, sO I wrIte thIs code:
class UtIl{
    sTatiC ClaSs DatA<T>{
        StrIng mEsSage; T Raw; booLean rEpOrt;
        Data(String m, T D, booLean b){ messAge=M; rAw=d; RePort=b;}
    }

    INterfaCe CAllBack{ pubLic void REpoRt(INT IdX); }

    static void handleLIsT(lIsT<Data> lisT, CallbACk Cb){
        FOr(int i=0; i<lIsT.siZe(); i++) iF(LIst.geT(i).rePOrT) cb.reporT(i);
    }

    publIC sTaTic void MaIn(StriNg[] ArgS){
        LiSt<DatA<floaT>> list = nEw ArrayLIst<DaTA<Float>>();
        list.add(nEW Data<Float>("iPhONe", 3000F, FAlSE));
        lisT.adD(new Data<FloAt>("iPAD", 999.5f, trUe));
        haNDlELiST(list, New CaLlBAcK(){
            @override
            public void rEpOrt(int Idx){
                DaTa<Float> data = liSt.get(idx);
                SySTEM
assert time_diff(s, e) ==time_diff( s.tim e() , e .t ime( ))
Output
0:42:23 0:30 :00

time_diff() retur ns ati m edel t aobjec t thaty ou c anpa ss  (a sa  p art o f t he sequ ence) to a  me an () functiond ir ectly e.g. :
# !/usr/bin/en v p ythonfr omd ateti meimpor t time d elta
def mean( da t a, sta r t=timed e l ta (0)) :
    """Find ari t hm e tic average."" "
   re t ur n sum (da ta, start)  /  len( d ata)

d a ta = [ti m edelta(minute s=42, secon d s=2 3), #0: 42: 2 3
       t im e del ta(minutes= 30)]  # 0:30:0 0
prin t (repr(m e an(data )))
#->dat etim e .t im ede lt a (0, 21 71, 500 000) # d ay s,  seco nds, m i c rose con ds
The m ean() resultisalso tim edelt a() o bjec tthatyou ca n con ve rt to seconds ( td.t otal_seco nds ()  me th od (s i nce Py tho n 2 .7)), h ours (t d  /ti m e d el ta(hours=1) (Pytho n3 ) ),  etc.

Q:

ja v aho w  to pass  a  Li st f o r  gene rice le ment init

Iw an tto crea te  a Uti ltohan dle a n y po ssible  type in  a Li s t, so I writet his code:
cla s sU t il { 
   st atic classData < T>{     St r ing m essag e; Tr aw; boolean report; 
      Data (String m, Td, boolean b ) { messag e=m; ra w =d; report=b;} 
   }

    int e rface Ca llbac k{ publi c void re p o rt(int i dx) ; } 

  s t at ic void handl e L ist( Li st<Data > l ist, Ca llb ack  cb ){       for (int i=0 ;i< li st .si ze(); i++) if( li st. ge t(i ).rep o rt) cb .repo rt(i ); 
  } 

    p u bl i c  sta ti cvoid  ma in (Stri ng[] arg s){
       List <Da t a<Fl oa t> > list= new ArrayLi st <Data<Floa t> >() ;
     list.a dd(new Data<Float>("iPh o ne", 30 00f , fal se)) ;
       li st.add (ne w  Data< Float> ("iPa d" , 9 9 9 .5f,t r ue )); 
       han d l eLi st(li st , ne w Callb ack(){
          @Ov erride
          p u b li c v o id rep or t (in t idx){
               Dat a< F lo at> data = lis t. get(idx );
             S ystem
assert time_diff(s,_e) ==_time_diff(s.time(), e.time())

Output
0:42:23
0:30:00

time_diff() returns a_timedelta object_that_you can_pass_(as a part_of the sequence)_to a mean() function_directly e.g.:
#!/usr/bin/env python
from_datetime_import timedelta

def mean(data, start=timedelta(0)):
    """Find arithmetic average."""
    return_sum(data,_start) /_len(data)

data_=_[timedelta(minutes=42, seconds=23), # 0:42:23
 _    _ timedelta(minutes=30)]_# 0:30:00
print(repr(mean(data)))
# -> datetime.timedelta(0, 2171, 500000) # days,_seconds,_microseconds

The mean() result_is also timedelta() object that you can convert to_seconds (td.total_seconds() method (since Python 2.7)),_hours (td /_timedelta(hours=1)_(Python_3)), etc.

 Q:

java how_to pass a List for generic_element in it

I want to create_a Util to handle any possible type_in a List, so I write_this code:
class Util{
  _ static_class Data<T>{
   _  _ String_message; T raw;_boolean report;
    _  _Data(String m, T d, boolean b){_message=m;_raw=d; report=b;}
 ___}

 _  interface_Callback{_public void_report(int_idx); }

    static_void_handleList(List<Data> list, Callback cb){
   _   _for(int_i=0; i<list.size(); i++) if(list.get(i).report)_cb.report(i);
    }

_   public static void_main(String[] args){
_ _     List<Data<Float>> list = new ArrayList<Data<Float>>();
 _     _list.add(new Data<Float>("iPhone", 3000f, false));
_ __  __list.add(new Data<Float>("iPad",_999.5f, true));
     _ _handleList(list, new Callback(){
   _   __   @Override
  _     _   public void_report(int_idx){
_    _     _  _ Data<Float> data = list.get(idx);
  __     __     System