by simultaneous writing of multiple threads, but achieving synchronization requires a high cost, so Accessing it is slower than accessing ArrayList.3. LinkedList is used to store data in a linked list structure, which is suitable for dynamic insertion and deletion of data, and is slow in random access and traversal. In addition, there is no method get,remove,insertlist defined in the interface, specifically for manipulating the header and footer elements, which can be used as stacks, queues, an
. While it is certainly possible to add and remove Java.util.List as a queue at the opposite ends, the new queue interface provides additional ways to support adding, removing, and checking collections, as follows:
public boolean offer(Object element) public Object remove() public Object poll() public Object element() public Object peek()
Basically, a queue is a first in first out (FIFO) data structure. Some queues have size limits, so if you want t
Microsoft has added a new concurrent programming framework to the C # (4.0) framework, and we can now develop programs that support concurrent concepts in C #. One of the most annoying things in concurrent programming is how to synchronize data: avoid dirty reads and dirty writes, of course we can do it through lock technology, or we can use the concurrent collections that Microsoft provides to us, which provide trydo methods. The read/write operation
()Returns an array of traversed (key, value) tuples as a list
7
Radiansdict.keys ()Returns a dictionary of all keys in a list
8
Radiansdict.setdefault (Key, Default=none)Similar to get (), but if the key does not exist in the dictionary, the key is added and the value is set to default
9
Radiansdict.update (DICT2)Update the key/value pairs of the dictionary dict2 to the Dict
10
Radiansdict.values ()Returns all values in
, there is a solution to the problem of calculating floating-point numbers by using integer numbers, for example, we will enlarge the above floating-point number first Ten times into integer data, and then the calculation ends and then shrinks Ten Times:(8+ 7 + 6 + 9)/4/10 //0.75(6+ 8 + 7 + 9)/4/10 //0.75Summarize:
when using For : in loops, do not rely on the order in which they are traversed.
when using Object type to hold the data, you need to ensure that the data in it is unordere
, intersection, and difference operations. So, if you want to perform some normal collection operations on the keys of the collection, you can use the key view objects directly without first converting them to a set.The dictionary's items () method returns an element view object that contains (key, value) pairs. This object also supports collection operations and can be used to find out which two dictionaries have the same key-value pairs.Although the values () method of the dictionary is simila
, and clear methods for that collection). But if the iterator calls its own remove method, it is still legal.3.List interfaceThe Java.util package inherits the collection interface. Here are just a few important methods. Public Interface extends Collection{ AnyType get (int idx); AnyType Set (int idx, AnyType newval); void Add (int idx, AnyType x); void Remove (int idx); Listiteratorint poss);}View CodeIndex 0 is in the front segment of the table, size ()-1 represents t
types:eg:li=[1,2,3,4,4,3,2]s = Set (LI)-------at this time S is a set, with no weight.eg:li={1,2,3,4,3,2}D = {}.fromkeys (LI); ----------the weight of the dictionary.Collections, like dictionaries, are non-smooth and do not slice, index, duplicate, or support joins, but support actions such as iteration (for), member lookups, and so on.The increase, deletion and modification of a set:Added: s={1,3,4,5}S.add (9)-------------add elements directly to the collection via the Add () function.S1 = {"H
1. Array to Liststring[] City = {"Nanjing", "Shanghai", "Beijing"}; ListNote: The list size of the array conversion is fixed, the Add, remove operation cannot be performed, or the following exception is thrown:Citylist.add ("Xiamen"); Citylist.remove (2);If you want to control the list size, you can only add the elements in the array to the list ...2. List Goto Arrayobject[] Cityarray = Citylist.toarray (); for (Object X:cityarray) System.out.println (x);Note: Since the list is converted to
element according to key value, if not present, return none2 Print(person1['name'])3 Print(Person1.get ('name'))4 Print(Person1.get ('name1','haha'))#If it does not exist, you can also set a default value5 6 7 dictionary operations: adding, modifying8 (if key does not exist, a new key-value pair will be added, and if present, the values of the key corresponding will be modified)9D = {'name':'Tom',' Age': 22}TenC |'Sex']='Mans' One Print(d)##输出结果: {' name ': ' Tom ', ' age ': $, ' sex ': ' Man
("First");5Set.add ("Second");6Set.add ("Third");7Set.add ("First");8Set.add ("Fourth One"));9System.out.println (Set.size ());//4Ten for(String str:set) { One System.out.println (str); A } - } -}Output Result:4A secondFourth oneA thirdFirst oneYou can see: 1. I added five elements to the set, with the same element, the value read out one. Describes the characteristics of non-repetition.2. The order of the output results is completely different from the order in which I add
.Stream and LambdaWrite a student class that has the following properties:Private Long ID;private String name;private int age;Private Gender gender;//enum typePrivate Boolean JOINSACM; Have you participated in the ACM contest?Creates a collection object, such as a list
Generic class: Generalstack
The Generalstack of jmu-java-05-collection of title set5.1 Code for Generalstack interface5.2 What are the benefits of generics compared to arraylistintegerstack in previous assignments?3.
= Max1 (stulist), can run successfully, where Stulist is List6.3 selected: Write int mycompare (t O1, T O2, Comparator C) method, This method can compare two user objects, or compare two Stuuser objects, the incoming comparator C can be Comparator3. Code Cloud and PTA topic set: jmu-java-05-Collection 3.1. Codes Cloud Code submission recordIn the Code cloud Project, select statistics-commits history-set time period, and then search for and3.2 PTA Problem set complete situation diagramTwo graphs
-step. One $(". DIV1 P"). HTML (data.person1.name) A }) - }) - }) the Script> - Head> - Body> - ButtonID= "BTN1">Click MeButton> + Divclass= "Div1"style= "width:300px;height:200px;border:1px solid red;"> - span>Request results The name of the first person is:span>BR/> + P>P> A Div> at Body> - HTML>JSON code1 {2"Person1":{3"Name": "Haha",4"Age": 21,5"City": "
One, there are three ways to delete a site collection:1. Open the SharePoint 2013 Admin page First---> Click on ' Application Management (Application Management) ' and go to this page---> click ' Delete a site collection Collection) ' and open the page---> select the site collection you want to delete and click the ' Delete ' button in the lower-right corner---> complete the deletion.2. Open the top site of the site collection you want to delete---> click the Gear button in the top right corner
1, can be indeterminate length, according to the actual need to add elements, can save space, and better solve the real problem. Arrays are fixed-length when initialized, and cannot be changed.2. The collection can add elements of any type, and the array must be of the same type.3, the collection can be achieved by the equals and Comparto methods to customize the comparison criteria of elements, to achieve any type of element comparison.4, the collection also has a lot of features, can solve mor
choose the best data structure.Several data structures that are simple to understand:
Arrays: The ability to query and replace quickly, but for larger arrays (changing the index of elements, and possibly generating expansion) and deleting (possibly altering the index of elements) can degrade performance;
Linked list (LinkedList):
A list element in a single necklace table contains: A saved content, a node pointing to the next list element;There is a node in the doubly linked li
Collection: Define a collection, set Stone a class, in the System.Collections library, you need an indexArrayList al = new ArrayList (); The collection is indexed as an array, and the index starts at 0 and adds the meaning of an int value.int i= al. Add (3);//print out an int value returned by index 0, which is the index of the added data in the collectionint a= al. ADD (5);int b= al. ADD (7);Al. Insert (1,9);//Inserts an index of 1 inserts a 9 at 1 on this index, insert data 9. The data of the
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.