The container class can greatly improve programming efficiency and programming capabilities, and in Java2, all containers are redesigned by Sun's Joshua Bloch to enrich the functionality of the Container class library.
The purpose of the Java2 container class library is "Save Object", which is divided into two categories:
Collection----A set of independent elem
C + + Primer learning Note _13_ Standard Template Library _list doubly linked list containerThe list container realizes the data structure of the doubly linked list, and the data elements are concatenated into a logical linear table through the linked list pointers, so that
default, is generally sequential, such as Integer, string comparison is ASCII code.
void L.splice (It pos, list x)void L.splice (It pos, list x, it i)void L.splice (It pos, list x, it first, it last)
To "cut" all the elements in the list x to the pos , it is simply a pointer operation, without assign
IntroductionDefined in header file namespacestd { template typename T, typename Allocator = allocatorclasslist;}A list is a container that supports fast insertion and deletion of elements in any location and does not support fast random access. It is implemented as a two-way linked list.Compared to Forward_list, it provides two-way iteration capability, but less space efficiency.Insert and del
Java container (list, set, map), javamapSimplified diagram of java container Class Library:
(Dotted boxes represent interfaces, while solid boxes represent common classes,
The hollow arrow indicates that a specific class implements the interface, and the solid arrow indicates that a Class Object indicated by the arrow can be generated for a class)
The main
original two setsin [+]: S1 = {1,2,3,4,5, ' a '}in [+]: S2 = {4,5,7,8, ' B ', ' C '}In []: S1.diffS1.differenceS1.difference_updateIn []: s1.difference (S2)OUT[28]: {1, 2, 3, ' a '}# minus sign can directly find the difference set of two setsIn []: S1-S2OUT[29]: {1, 2, 3, ' a '}3.5.2 Difference_update Two sets of differences, but modifies the original collection, does not return a valuein [+]: S1OUT[30]: {1, 2, 3, 4, 5, ' a '}In [to]: S2OUT[31]: {4, 5, 7, 8, ' B ', ' C '}in [+]: s1.difference_u
can be generated using derivation-List derivation format: [Expression for item ' in Iterable if condition],if filter condition can be omitted, the same format applies to tuple and set, but the brackets need to be modified to () and {} respectivelyA_list = [n for n in range (1, ten) if n% 2 = = 0]Print (a_list) $, [2, 4, 6, 8]-Dictionary derivation format: {key_expression:value_expression for expression in iterable}A_list = [n for n in range (1, 5)]B_
First, the containerMany times, the program always creates new objects based on certain conditions that the runtime knows about, and before that the number of objects required, and even the type of the object, is required to hold the object. The Java container class can automatically adjust its size. A container class library can be divided into two different concepts:
Collection. A sequence of ind
(total).//2) Removes the first element of the list to sort and merges it with the first (i=0th) bucket.//3) If, before the merge, the ith bucket is not empty, the merge the ith buckets with the i+1th bucket.//4) Repeat Step 3 until we merge with an empty bucket.//5) Repeat Step 2 and 3 until the list to sort is empty.//6) Merge all the remaining non-empty buckets together starting from smallest to largest.
elements inside the container is a hard work, because the memory of all the data units are not contiguous, the list has only one history deleted.Related PostsSee: Simple analysis of common usages in C + + stack queue vectorsDetailed Address: http://blog.csdn.net/u013630349/article/details/46860117Level 1-Used as map only: use static arrayLevel 2-Saves fixed-length data, which is also used for all traversal
The list container corresponds to a list of common data structures. The list container supports fast random inserts, deletes, but does not support fast random access elements; This is not the same as the vector container, vector c
The member function unique () can ensure that two consecutive objects in the linked list container are unique. That is, the element values of any consecutive objects in the linked list container must be different, however, the uniqueness of all objects in the linked list
List-excel at inserting a deleted listA linked list is the opposite of an array.The array itself is not dynamically growing (the program must also reopen the memory to implement).and the strong link list is the ability to dynamically grow and delete.But for an array of intrepid random access capabilities, the list is w
, it is important to note that the elements that can be saved are larger than the vector. There is also a high performance when adding elements in front and back without moving the elements of other blocks.Therefore, in the actual use, how to choose which of the three containers, should be based on your needs, should generally follow the followingPrinciple of:1. If you need efficient immediate access, without the efficiency of insert and delete, use vector2, if you need a large number of inserti
This is a creation in
Article, where the information may have evolved or changed.
The container in the go language are heap, list, ring, and no stack.
Where heap is the priority queue, although there is a push ()/pop () interface, use the heap to implement the heap. Interface interface, not concise.
So here's a simple stack with a list that's left for him to use.
I write a simple program to distinguish between the vector container size () and the capacity () function, where the capacity function is to reserve space for the vector container, without having to reallocate the memory every time the element is added, thus improving the efficiency a lot. I through a small program to study, the following is the program and running results, more concise can be seen capacity
Directory
1. Preface
2 Queue Internal structure
2.1 Definition of the node
2.2 Why the next pointer inside the node needs an atomic update
2.3 Internal member variables for queues
3. Building a lock-free concurrent queue based on CAS algorithm and unidirectional linked list
3.1 Team-out method
3.2 Queue method
4. Performance Testing
5. Summary
1. Preface
We build our own lock-free queue b
The two word "container" is quoted because the class does not implement the Collection interface. To write a class with List function and map function, there are several difficulties, one is that Java does not allow both the list and map two interfaces to be implemented simultaneously, and the second is that the LISTMAP combines the functions of the two and produ
)In [the]: lOUT[92]: In [the]: L.next ()OUT[93]: 2In [94]: L.next ()OUT[94]: 3An iterator is a lazy evaluation that is only used to calculate the value, otherwise it will not. The list is the first to find out all the values. So when the data is large, iterators have better performance.List parsing with conditions[Expression for item ' in iterator if condition] is append to the list and returned when the co
Java Container---List,map,setCollection├list│├linkedlist│├arraylist│└vector│└stack└setMap├hashtable├hashmap└weakhashmapCollection is the most basic set interface, a collection represents a set of Object,java SDK does not provide directly inherit from the collection class, the Java SDK provides classes are inherited from the collection "sub-interface" such as
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.