Ext. util. mixedcollection usage

Source: Internet
Author: User

Looking at the extjs source code, we found that there are many mixedcollections. It is a collection class that contains both a digital index and a key, and exposes related events. It is equivalent to map and list in Java, and has four events: add element, remove element, replace element, clear set clear

(1) Let's see how it works.


1 // General Method
2 var MC = new Ext. util. mixedcollection ();
3 MC. Add (someel. Dom. ID, someel );
4 MC. Add (otherel. Dom. ID, otherel );
5 // and so on
6
7 // use getkey
8 var MC = new Ext. util. mixedcollection ();
9 MC. getkey = function (EL ){
10 return El. Dom. ID;
11 };
12 MC. Add (someel );
13 MC. Add (otherel );
14
15 // or through the constructor
16 var MC = new Ext. util. mixedcollection (false, function (EL ){
17 return El. Dom. ID;
18 });
19 MC. Add (someel );
20 MC. Add (otherel );
 
1 // General Method
2 var MC = new Ext. util. mixedcollection ();
3 MC. Add (someel. Dom. ID, someel );
4 MC. Add (otherel. Dom. ID, otherel );
5 // and so on
6
7 // use getkey
8 var MC = new Ext. util. mixedcollection ();
9 MC. getkey = function (EL ){
10 return El. Dom. ID;
11 };
12 MC. Add (someel );
13 MC. Add (otherel );
14
15 // or through the constructor
16 var MC = new Ext. util. mixedcollection (false, function (EL ){
17 return El. Dom. ID;
18 });
19 MC. Add (someel );
20 MC. Add (otherel );

(2) Add and call the add method. The addall method is used to add an array or object. IfallowFunctionsSetTrue, Then the function reference will also be added to the set.

(3) four methods are used for the value. The item method returns the project bound to the passed key or index. The key has a higher priority than the index. This is equivalent to calling the key first, and then calling itemat if there is no project match. That is, their priority is item (String/Number key), Key (String/Number key)-> Get (Number index)-> Itemat (Number index)

(4) common methods such as each, contains, and remove

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.