In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Today let's take a look at sorting, so what is sorting? Sorting is an operation that is often carried out inside the computer, and its purpose is to adjust a set of "unordered" data elements to "ordered" data elements. So what is the mathematical definition of sorting? As follows
Let's look at a concept: the stability of ordering. What is the stability of sorting? It means that if there are two data elements r [I] and r [j] in the sequence, their keywords k [I] = = k [j], and before sorting, the object r [I] precedes r [j]; if after sorting, the object r [I] is still in front of r [j], the sorting method is said to be stable, otherwise it is said to be unstable.
Let's take a look at multi-keyword sorting. This is that there is more than one keyword to compare when sorting, so what does it mean? That is, when the sorting results are sorted first by keyword 1, by keyword 2 when keyword 1 is the same, and by keyword n when the keyword nmai 1 is the same. For multi-keyword sorting, we only need to consider multiple keywords at the same time when comparing operations. Let's analyze it through a sample code.
# include # include "Object.h" using namespace std;using namespace DTLib;struct Test: public Object {int key1; int key2; Test (int K1, int K2) {key1 = K1; key2 = k2;} bool operator = = (const Test& t) {return (key1 = = t.key1) & & (key2 = = t.key2) } bool operator! = (const Test& t) {return! (* this = = t);} bool operator > (const Test& t) {return (key1 > t.key1) | ((key1 = t.key1) & & (key2 > t.key2));} bool operator t);} bool operator = (const Test& t) {return! (* this < t);}} Int main () {Test T1 (3,4); Test T2 (3,5); Test T3 (2,4); Test T4 (1,2); cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.