First of all, I would first emphasize that I am a weak chicken farm, this essay is in my study Python3 in the tuple, dictionary, list, set these four kinds of common data types of some feelings, if there is something wrong to welcome everyone to correct. Thank you, everyone.Back to the point: This essay discusses lists, dictionaries, tuples, and collections. Therefore, it is necessary to make a brief analysis of three kinds of data types first:1: List
is, the List is rearranged based on the input of the random source, which has the same probability (assuming that the random source is fair). This algorithm is very useful in implementing a game of chance. For example, it can be used to mix a List of card objects that represent a deck of cards. In addition, it is also useful when generating test cases.Collections.shuffling (list)4) Inversion (Reverse)Use the reverse method to sort the specified list in descending order based on the natural orde
TreeSet and TreeMap sorting when comparing elements require element objects to implement comparable interfacesThere are two ways to compare elements in the collections sort method:Element object implementation comparable interfaceEntity class Dog1 Public classDogImplementsCloneable,comparable {2 3 PrivateString name;4 PrivateString age;5 6 PublicString GetName () {7 returnname;8 }9 Public voidsetName (String name) {T
* 2. Variable parameter, must be written in the last one of the parameter list */public static void function (OBJECT...O) { }/* * Definition method, calculates the variable parameter implementation of 10 integers and * methods */public static int get Sum (int ... a) {int sum = 0; for (int i:a) {sum = sum + i;} return sum;}}Third, collections--collection implementation classAre all under the list implementation class1. Sorting/* * collections.sort s
/*** Split Collection* @param * @param reslist the collection to split* @param count the number of elements per collection* @return returns the individual collections after splitting*/public static if (Reslist==null | | COUNTreturn null;Listint size=reslist.size ();if (sizeRet.add (reslist);}else{int pre=size/count;int last=size%count;Previous pre set, each size count elementfor (int i=0;iListfor (int j=0;jItemlist.add (Reslist.get (i*count+j));}Ret.a
Summarize the conversion between the Java object and the collection and JSON:1. Create the User class:Package Com.ghj.packageofdomain;public class User {private int id;private string Name;private string Gender;public User () {}public User (int id, string name, String gender) {this.id = Id;this.name = Name;this.gender = gender;} public int getId () {return ID;} public void setId (int id) {this.id = ID;} Public String GetName () {return name;} public void SetName (String name) {this.name = name;}
objects are the same object and are treated as two objects. All when overriding the Equals method of a class that must be put into treeset, you should ensure that the results are consistent with the CompareTo method.If a mutable object is added to TreeSet, and the subsequent program modifies the object's properties, causing it to change in size with other objects, the TreeSet does not adjust their order again, even causing the saved two objects to return true through equals. The CompareTo retur
This question describes the Collections tool Class two sort () methods, as follows:
One, Collections tool Class two sort () method
Format one: public static
Description: The generics
Overwrite equals () and CompareTo () methods. such as the string class, the integer class are comparable interface subclasses, can be sorted, and the base type cannot be sorted. Comparison items are specified within a cla
As the name of this data structure says, it records the order in which each key-value pair is added.
D = ordereddict ()
d[' a '] = 1
d[' B '] = ten
d[' C '] = 8 for letter in
D:
Print Letter
Output:
A
b
c
If multiple parameters are passed in at the same time, their order is random and is not stored in the order of location.
>>> d = ordereddict (A=1, b=2, c=3)
ordereddict ([(' A ', 1), (' C ', 3), (' B ', 2)]
In addition to the same methods as normal D
Concept distinction: java.util.Collection and java.util.Collections differences:
1, Java.util.Collection is a collection interface (a top-level interface of the collection Class). It provides a common interface method for basic operations on a collection object. The collection interface has many specific implementations in the Java class Library. The significance of the collection interface is to provide a maximum unified operation for a variety of specific sets, and its direct inheritance inter
Equals method, when the object used in the map as a key in the Hashcode method, so the efficiency is higher. Hashcode can be useful when the object is used as a key.Two objects if they are equals, then their hashcode must be equal.
The differences between the hashmap,hashset,arraylist and the LinkedList collections, and their respective usages:
The HASHMAP:HASHMAP implements the map interface, and the bottom uses the hash algorithm to store the data.
introduced a generic set, which forces the elements inside to be specified as a specific type (or template), it is a good thing to set ArrayList sets and array arrays.
1. Array
The System.Array class is the base of an array from which the array is derived. All. NET array and set subscript starting from 0, the use of the array is relatively simple, before VB and other programming languages have used more than N, here no longer repeat.
2. Collection--arraylist
The collection (
Remember the textbook: "If you need to use multiple objects of the same type, you can use collections and arrays." "Yes, nothing wrong. Just the size of the array is fixed. If the number of elements is dynamic, you should use the collection class. In the. NET framework, there are many collections, such as list
One, array
In practical applications, arrays can be divided into: simple arrays, multidimensiona
sorted from new to old.Db.my_collection.find (). Sort ({"$ natural":-1})Circular cursorsA circular cursor (tailablecursor) is a special kind of cursor that is not closed when the result set of a loop cursor is taken out of the light. The loop cursor is inspired by the tail-f command (a circular cursor is a bit similar to this command) and will continue to extract the output as long as possible. Because the loop cursor is not closed after the result set has been taken, the loop cursor continues
Tags: The conceptual relational database performs an insert email operation to get sudo dataNon-relational database
command is case-sensitive; command Terminator is carriage return (unlike MySQL)
MongoDB Configuration
sudo service mongodb start
mongo
MongoDB Basic Concept
集合A concept that corresponds to a relational database 表 , creating a collection: db.createCollections(" ; Deleting a collection: db. ; getting all the collections:show
Tags: RTO 1.3 Show technology share Batch weight class img variableFirst, collection (table of corresponding database) 1, view all the collections in the current libraryShow collections2. Create new collection explicitlyDb.createcollection ("user")Implicitly-CreatedDb. user. Insert ({name: "Zhangsan"})3. Deleting a CollectionDb. user. Dorpcollection ()Ii. documents (rows in the corresponding database) 1, new (insert, save, Insertone/insertmany) 1.1, N
Over the past few days, I 've learned Kent Beck's implementation patterns, probably because I just finished reading design patterns and thought the author's language was too casual, design patterns is more logical.
The so-called implementation mode also lacks some programming skills. From the perspective of the design mode, it is just a trick.
In addition, the book is far-fetched in many places. Maybe because I am not a Java programmer, a lot of content in the book cannot be understood, but I st
Apache Commons CollectionsTags: collectionsapachehashmapcommandobjectjavadoc 2012-05-09 10:13 1070 people read Comments (0) Favorites Report Category: Java Programming (74)
Directory (?) [+]Original Http://blog.csdn.net/sunjavaduke/archive/2008/03/24/2214806.aspx This paper briefly introduces the content of collections frame in Apache Commons. This article is mainly based on the Apache official website overview, userguide and Javadoc translation. If t
Java. util. Collections class package Learning1. Description:1.1 OverviewThe Java. util. Collections class contains many useful methods that can make the programmer's work easier, but these methods are generally not fully utilized. Javadoc provides the most complete description of the collections class: "This class contains a dedicated static class that can be 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.