Dart collection

/ * 
List which common attributes and methods: 

    common attributes: 
        length length 
        reversed flip 
        isEmpty is empty 
        isNotEmpty if not empty 
    common methods:   
        the Add increase 
        addAll splice array 
        indexOf to find specific values passed 
        remove Remove passed specific value 
        removeAt delete incoming index value 
        fillRange modified    
        insert (index, value); specified position inserted     
        insertAll (index, list) specified position inserted List 
        toList () is converted into other types List   
        the Join () is converted into a string List 
        split () is converted into string List 
        forEach    
        Map 
        where
        the any
        Every 

* / 


void main () { 

  // List myList = [ 'banana', 'apple', 'watermelon'];
   // Print (myList [. 1]); 


  // var = new new List List ();
   // List .add ( '111');
   // List.add ( '222');
   // Print (List); 


// List inside attributes:
     // List myList = [ 'banana', 'apple', 'watermelon' ];
     // Print (myList.length);
     // Print (myList.isEmpty);
     // Print (myList.isNotEmpty);
     // Print (myList.reversed);   // list sort descending
     // var newMyList = myList .reversed.toList ();
     //Print (newMyList); 

// List which method: 


    // List myList = [ 'banana', 'apple', 'watermelon'];
     // myList.add ( 'peach');    // increased to increase a data 

    // myList.addAll ([ 'peach', 'grapes']);   // splicing array 

    // Print (myList); 

    // Print (myList.indexOf ( 'apple fruit x'));     // look-up data can not find indexOf -1 returns the index to find 

    // myList.remove ( 'watermelon'); 

    // myList.removeAt (. 1); 

    // Print (myList); 
  

    // List myList = [ 'banana', 'apple', ' watermelon ']; 

    // myList.fillRange (. 1, 2,' AAA ');   // modify 

    //   myList.fillRange (. 1,. 3,  'aaa');  


    //myList.insert (. 1, 'AAA');       // insert a 

    // myList.insertAll (. 1, [ 'AAA', 'BBB']);   // Insert plurality 

    // Print (myList); 


    // List myList = [ 'banana', 'apple', 'watermelon']; 

    // var = myList.join STR ( '-');    // List converted to a string 

    // Print (STR); 

    // Print (string STR IS );   // to true 


    var STR = 'banana - Apple - watermelon' ; 

    var List = str.split ( '-' ); 

    Print (List); 

    Print (List List IS); 


}
// the Set 

// with its main function is removed duplicate content array 

// the Set sequence is not set and can not be repeated, it is not feasible to obtain an index value 

void main () { 

  
  // var new new the Set S = ();
   // s.add ( 'banana');
   // s.add ( 'apple');
   // s.add ( 'apple'); 

  // Print (S);    // {bananas, apples} 

  // Print (s.toList ()); 


  List myList = [ 'banana', 'apple', 'watermelon', 'banana', 'apple', 'banana', 'apple' ]; 

  var S = new new the Set (); 

  S .addAll (myList); 

  Print (S); 

  Print (s.toList ()); 


  
}
/ * 
  Map (Maps) are unordered key-value pair: 

    common attributes: 
        Keys to get all the key values 
        values values get all the value 
        isEmpty is empty 
        isNotEmpty if not empty 
    : a common method 
        of data remove (key) to delete the specified key 
        addAll ({...}) mapped to the combined increase attribute mapping 
        containsValue view map returns a value within the to true / to false 
        forEach    
        Map 
        WHERE 
        the any 
        Every 


* / 

void main () { 

 
  // the Map Person = {
   //    "name": " Joe Smith ",
   //    " Age ": 20 is
   // }; 


  // var new new m = the Map ();
   // m["name"]="李四";
  
  // print(person);
  // print(m);

//常用属性:

    // Map person={
    //   "name":"张三",
    //   "age":20,
    //   "sex":"男"
    // };

    // print(person.keys.toList());
    // print(person.values.toList());
    // print(person.isEmpty);
    // print(person.isNotEmpty);


//常用方法:
    Map person={
      "name":"张三",
      "age":20,
      "sex":"男"
    };

    // person.addAll({
    //    "Work": [ "knock code ',' food delivery '],
     //    " height ": 160.
     // }); 

    // Print (Person); 



    // person.remove (" Sex ");
     // Print (Person); 



    Print (person.containsValue ( 'John Doe' )); 
}
/*
        forEach     
        map         
        where       
        any
        every
*/
void main(){


      //  List myList=['香蕉','苹果','西瓜'];

      // for(var i=0;i<myList.length;i++){
      //   print(myList[i]);
      // }


      // for(var item in myList){
      //   print(item);
      // }


      // myList.forEach((value){
      //     print("$value");
      // });





      // List myList=[1,3,4];

      // List newList=new List();

      // for(var i=0;i<myList.length;i++){

      //   newList.add(myList[i]*2);
      // }
      // print(newList);





      // List myList=[1,3,4];      
      // var newList=myList.map((value){
      //     return value*2;
      // });
      //  print(newList.toList());





      // List myList=[1,3,4,5,7,8,9];

      // var newList=myList.where((value){
      //     return value>5;
      // });
      // print(newList.toList());
     // List myList=[1,3,4,5,7,8,9];

      //myList.any F = var ((value) {    // long as there are satisfied the conditions set return to true 

      //      return value>. 5;
       // });
       // Print (F); 

      // List myList = [. 1, 3,4,5,7,8,9]; 

      // var myList.every F = ((value) {    // each satisfy the conditions otherwise returns true to false 

      //      return value>. 5;
       // });
       // Print (F); 

      // SET 

      // var new new the Set S = (); 

      // s.addAll ([1,222,333]); 

      // s.forEach ((value) => Print (value)); 

      // Map 

       the Map Person = {
           "name": "San",
          "age":20
        };

        person.forEach((key,value){            
            print("$key---$value");
        });

}

 

Guess you like

Origin www.cnblogs.com/loaderman/p/11026441.html