(i) Collections and arraysArrays: (with basic data Types )-a container for the storage object, fixed in length , "not suitable for use with unknown number of objects"Collection: (The object type can be different)- variable length , which can be used in most cases.(ii) Hierarchical relationship1.0: In the figure, the solid line border is the implementation class, the polyline border is an abstract class, and the point line border is the interface:2.0
digit of the list
Collections Collection Tool classJava.util.Collections Collection Tool classCollections Private parameterless construction method, the inside method is all static, through the class name can be directly usedCollections Common methods:1. static void Shuffle (listreplaces the specified list with a default random source (disrupts the order of elements in the collection)2.static void sort (listsorts the specified list in ascending
1 Packagecom.jdk7.chapter4;2 3 Importjava.util.ArrayList;4 Importjava.util.LinkedList;5 Importjava.util.List;6 ImportJava.util.ListIterator;7 ImportJava.util.Stack;8 ImportJava.util.Vector;9 /**Ten * List of forms of collections in Java (sequential allow repetition) One * List of three forms of expression ArrayList, Vector, LinkedList A * where stack extends Vector - * Another: The list of Listiterator can manipulate the listing elements - * @author
Namedtuple is named tuple, more like struct in C language. In general, the tuple is (item1, item2, Item3,...), all the item can only be accessed according to the index, there is no clear name, and Namedtuple is in advance of these item name, can be easily accessed later.
From collections import Namedtuple
# Initialization requires two parameters, the first is name, and the second parameter is a list of all item names.
coordinate = namedtuple
Most collections are system.collections,system.collections.generic two namespaces. Where System.Collections.Generic is specifically used for generic collections.
The collection type for a particular type is located in the System.Collections.Specialized namespace;
The thread-Safe collection class is located in the System.Collections.Concurrent namespace.
The following are the interfaces for collection and li
unsupportedoperationexception. Exceptions is covered in Chapter 9.
Table I
* This is an "optional" method, and some collections may not implement it. If this is the case, the method will encounter a unsupportedoperatiionexception, that is, an "operation does not support" violation, as detailed in chapter 9th.The following example shows you all the methods. Similarly, they are only valid for things inherited from the collection, and a Array
to implement collection functionality under the Collections namespace, and provides developers with flexible selectivity depending on the application environment: such as extensive ArrayList and StringCollection via index access ; a first-in, first-out, first out stack that is typically released after retrieval; access to its elements through element keys Hashtable, SortedList, ListDictionary, and StringDictionary NameObjectCollectionBase and NameVal
(){"_id": ObjectId ("5a43a73ba889535e61dc29a8"), "name": "Zhanghongfeng", "Age": 33}{"_id": ObjectId ("5a43a77ba889535e61dc29a9"), "name": "Maple", "Age": 32}Insert a document again> Db.fixedcollection.insert ({"Name": "ZHF", "Age": 32})Writeresult ({"ninserted": 1})By querying, you can see that the oldest inserted document, Name:zhanghongfeng , was replaced when a document was inserted. This is because we specify a maximum number of 2 documents in a fixed collection . As a result, the newly i
with $ 4. Cannot be included. (Point number) 5. Keys are case-sensitive and cannot be duplicated for example: {foo:1,foo:1} The naming of collections requires attention to the following points: 1. The collection name cannot be an empty string ("") 2. The collection name cannot contain the \ s character (null character), which represents the end of the collection name 3. The collection name cannot be "system." At the beginning, the prefix is reserved
This article describes how to use the Python built-in module collections. the sample code is based on Python 2.x. if you need it, refer to collections as a collection module built in Python, provides many useful collection classes.
Namedtuple
We know that tuple can represent the unchanged set. for example, the two-dimensional coordinates of a point can be expressed:
>>> p = (1, 2)
However, when we see (
# Undertake software automation implementation and training and other gtalk: ouyangchongwu # gmail.com qq 37391319 blog: Shenzhen test automation python Project Access Group 113938272 Shenzhen accounting software test part-time job 6089740 # Shenzhen stall group 66250781 wugang cave Chengbu Xinning township sentiment group 49494279 1.3 collections-the main types of container data are as follows: namedtuple (). Create a factory function that contains t
There are some of the more useful types in the collections module, which are some of the basic types of extensions that are necessary for one of the modules
Counter (counter)
Can track the number of occurrences of a value, and is arranged from large to small>>> Import collections>>> C1 = collections. Counter (' ADADWEFFFCVCC ') >>> c1counter ({' C '
Nonsense opening
To meet project requirements, you need to systematically Understand Java Collections. Therefore, you can easily record and serve others.Java Collections
The Java Collections framework consists of four parts: interfaces, implementations, aggregate operations, and algorithms. Subsequent articles will also introduce these four parts separately.Java
This article mainly introduces the use of Python's built-in module collections tutorial, the sample code based on the python2.x version, the need for friends can refer to the
Collections is a collection module built in Python that provides a number of useful collection classes.
Namedtuple
We know that tuple can represent invariant sets, for example, the two-dimensional coordinates of a point can be expre
First, what is the moduleCommon scenario: A module is a file that contains Python definitions and declarations, and the file name is the suffix of the module name plus the. Py.In fact, the import loaded module is divided into four general categories:1 code written using Python (. py file)2 C or C + + extensions that have been compiled as shared libraries or DLLs3 packages for a set of modules4 built-in modules written and linked to the Python interpreter using CWhy use a module?If you quit the P
); intINDEX4 =collections.lastindexofsublist (List2, sublist); System.out.println (INDEX4); //replaces the specified element in the collection, or returns False if the element exists that returns true BooleanFlag = Collections.replaceall (List2, "Sunday", "TTTTTT"); SYSTEM.OUT.PRINTLN (flag); System.out.println (LIST2); //reverses the order of elements in the collectionCollections.reverse (LIST2); System.out.println (LIST2); //swap the position of the s
1. Use an extension method to use an enumeration value for the Description property value Public Static classenumextenstion{ Public Static stringGetdescriptionname ( ThisEnum Enumvalue) {Object[] attr =Enumvalue.gettype (). GetField (Enumvalue.tostring ()). GetCustomAttributes (typeof(DescriptionAttribute),false);if(attr. Length >0)return((DescriptionAttribute) attr[0]). Description;return "";}}2, gets the enumeration Description property value and the enumeration value for the relationship/// /
constructorArrayList list=new ArrayList ();for (int i=0;i② is constructed with a Icolliction objectArrayList list=new ArrayList (arryname)③ Initializes an internal array with the specified sizeArrayList list=new ArrayList (n);2, the addition of ArrayList elements①add method adds an element at the end②insert method Insert (index,value) index, value3. ArrayList element deletion①clear method to remove all elementsThe ②remove method removes the first object of a specified object, remove (OBJ)③remov
the form of Key=value in the Map collection.boolean equals(Object o)Determines whether the elements of the two set set are the sameThe lower level also overrides the Equals methodWhen we look at the HashMap collection, we do not find the Equals method, so we go to his parent class. V get(Object key)Gets the value of the corresponding element according to the key of the element in the Map collectionint hashcode()Returns the hash code value of the Map collectionboolean isEmpty()Checks out if ther
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.