策略模式之排序算法

java策略模式(排序算法) java设计模式中策略模式的一个实例:选择不同的排序算法(①冒泡排序;②插入排序;③选择排序)对数组进行排序。 立即下载

策略模式(Strategy):它定义了算法家族,分别封装起来,让它们之间可以相互替换,此模式让算法的变化,不会影响到使用算法的客户。
在这里插入图片描述
排序接口:
isort.h

#pragma once

class ISort
{
public:
	virtual ~ISort() {}
	virtual void doSort(int a[], int len) = 0;
};

冒泡排序算法类bobbleSort.h

#pragma once

#include "isort.h"

class BobbleSort : public ISort
{
public:
	void doSort(int arr[], int len) override
	{
		if (len <= 1)
			return;

		int temp;  //此算法有改进方式,这里主要为了演示设计模式
		for (int i = 0; i < len - 1; i++)
		{
			for (int j = 1; j < len - i; j++)
			{
				if (arr[j] < arr[j - 1])
				{
					temp = arr[j];
					arr[j] = arr[j - 1];
					arr[j - 1] = temp;
				}
			}
		}
	}
};

插入排序算法类insertSort.h:

#pragma once

#include "isort.h"

class InsertSort : public ISort
{
public:
	void doSort(int arr[], int len) override
	{
		if (len <= 1)
			return;

		int temp;
		for (int i = 1; i < len; i++)
		{
			for (int j = i - 1; j >= 0; j--)
			{
				if (arr[j] > arr[j + 1])
				{
					temp = arr[j];
					arr[j] = arr[j + 1];
					arr[j + 1] = temp;
				}
				else
				{
					break;
				}
			}
		}
	}
};

选择排序算法类selectSort:

#pragma once

#include "isort.h"

class SelectSort : public ISort
{
public:
	void doSort(int arr[], int len) override
	{
		if (len <= 1)
			return;

		int temp;
		for (int i = 0; i < len - 1; i++)
		{
			int minIndex = i;
			for (int j = i + 1; j < len; j++)
			{
				if (arr[j] < arr[minIndex])
					minIndex = j;
			}
			temp = arr[i];
			arr[i] = arr[minIndex];
			arr[minIndex] = temp;
		}
	}
};

快速排序算法类quickSort.h

#pragma once

#include "isort.h"

class QuickSort : public ISort
{
public:
	void doSort(int arr[], int len) override
	{
		if (len <= 1)
			return;

		quickSort(arr, 0, len-1);//注意最后一个参数是len-1
	}

private:

	int quickSortPartition(int s[], int l, int r) {
		//Swap(s[l], s[(l + r) / 2]); //若以中间数为基准,则先将中间的这个数和第一个数交换即可
		int i = l, j = r, x = s[l]; //将最左元素记录到x中
		while (i < j)
		{
			// 从右向左找第一个<x的数
			// 无需考虑下标越界
			while (i < j && s[j] >= x)
				j--;
			if (i < j)
				s[i++] = s[j]; //直接替换掉最左元素(已在x中存有备份)

			// 从左向右找第一个>x的数
			while (i < j && s[i] <= x)
				i++;
			if (i < j)
				//替换掉最右元素(已在最左元素中有备份)
				//最左元素一定被覆盖过,若没有,则表明右侧所有元素都>x,那么算法将终止
				s[j--] = s[i];
		}
		s[i] = x;  //i的位置放了x,所以其左侧都小于x,右侧y都大于x
		return i;
	}

	void quickSort(int s[], int l, int r)
	{
		//数组左界<右界才有意义,否则说明都已排好,直接返回即可
		if (l >= r) {
			return;
		}

		// 划分,返回基准点位置
		int i = quickSortPartition(s, l, r);

		// 递归处理左右两部分,i处为分界点,不用管i了
		quickSort(s, l, i - 1);
		quickSort(s, i + 1, r);
	}
};

context.h

#pragma once

#include "isort.h"

class Context
{
public:
	Context(ISort *sortBase)
	{
		m_sortBase = sortBase;
	}

	void startSort(int arr[], int len)
	{
		if (m_sortBase != nullptr)
		{
			m_sortBase->doSort(arr, len);
		}
	}

private:
	ISort *m_sortBase;
};

客户端程序:

#include "context.h"
#include <iostream>
#include "bobbleSort.h"
#include "quickSort.h"
#include "insertSort.h"
#include "selectSort.h"

//数组打印
void printArray(int a[], int len)
{
	for (int i = 0; i < len; ++i)
		std::cout << a[i] << " ";
	std::cout << std::endl;
}

int main()
{
	const int len = 5;
	int arr[len] = { 3, -5, -6, 5, 6 };
	printArray(arr, len);

	std::cout << "排序后:" << std::endl;

	ISort* sortAlgorithm = new QuickSort();  //或者ISort* sortAlgorithm = new QuickSort();根据需要选择算法类
	Context* context = new Context(sortAlgorithm);
	context->startSort(arr, len);

	printArray(arr, len);

	delete sortAlgorithm;
	delete context;

	getchar();
	return 0;
}

运行结果:

3 -5 -6 5 6
排序后:
-6 -5 3 5 6

参考:
策略模式-排序算法

C++ 策略模式调用不同的排序算法

排序与设计模式

各种排序算法的策略模式实现 策略模式实现冒泡、快排、归并三种算法,并比较其排序时间 立即下载

相关推荐

关于Arduino中的常用函数

一、I/O函数 二、时间函数 三、数学函数 abs 返回其参数的无符号值 【abs(12)返回12,abs(-12)也返回12】 constrain 限制一个数字以阻止它超出范围。第一个参数是被限制的数字,第二个参数是范围区间的开始,第三个参数是允许的数字范围区间的结尾。 【constrain(8,1,10)返回8,constrain(11,1,10)返回10,constrain(0,1,10)返回1】 map 将一个范围内的数字映射到另一个范围。第一个参数是要映射到数字,第二个和第三个参数是from范围(

TREE的博客 7334

你真的会排序吗?一次搞定九大排序策略

14.1 冒泡排序原理:从左到右,相邻元素进行比较,如果前一个元素值大于后一个元素值(正序),则交换,这样一轮下来,将最大的数在最右边冒泡出来。这样一轮一轮下来,最后实现从小到大排序。动图...

祈澈菇凉 820

[Windows] 发票识别工具。支持xml、pdf、ofd文件。

发票识别是财务自动化中的关键环节,支持多种格式(XML、PDF、OFD)的识别工具能显著提升工作效率。以下介绍基于Windows平台开发此类工具的技术方案。发票识别是财务自动化中的关键环节,支持多种格式(XML、PDF、OFD)的识别工具能显著提升工作效率。以下介绍基于Windows平台开发此类工具的技术方案。

pZC_dqux的博客 679

策略模式经典案例【排序算法】

策略模式(Strategy Pattern)是一种行为型设计模式,它定义了一系列算法,将每个算法都封装起来,并且使它们可以相互替换。策略模式可以让算法的变化独立于使用它们的客户端,从而提高了系统的灵活性和可维护性。

『愚』的博客 1236

ROS与UR10e机械臂实战:从零搭建到精准控制

本文详细介绍了如何从零开始搭建ROS与UR10e机械臂的开发环境,包括硬件准备、软件配置、网络设置以及MoveIt!运动控制实战。通过具体的代码示例和常见问题排查,帮助开发者快速掌握UR10e机械臂的精准控制技术,适用于工业自动化和实验室研究场景。

m3n5b7v8c9x的博客 777

GWAS与eQTL相结合,进一步筛选疾病相关基因

欢迎关注”生信修炼手册”!在GWAS分析结果中,大部分显著的SNP位点都位于非编码区,很难直接挖掘这些位点的调控机制。通常假设与疾病关联的SNP位点通过调控基因表达来发挥作用,而eQTL...

庐州月光的博客 1万+

设计模式之策略模式

1

chitudoupi的专栏 445

用STC8单片机解码EV1527遥控信号:从波形分析到C代码实现(附完整库)

本文详细介绍了如何使用STC8单片机解码EV1527遥控信号,从波形分析到C代码实现的完整过程。内容包括EV1527协议解析、硬件搭建、信号捕获技巧、解码算法实现及优化策略,并附有完整库代码,帮助开发者快速实现智能家居设备的无线控制。

weixin_34093995的博客 303

java 中的策略设计模式之排序算法示例

1、环境介绍: eclipse 2018版 + jdk1.8 + 原始xml解析(不借助第三方jar包) 本文灵感来源:重点大学软件工程规划系列教材 设计模式 清华大学出版社 2、程序设计简析 策略设计模式的定义:定义一系列算法,将每一个算法 封装起来,并让他们可以互相替换。 举一个例子: 今天早上你没有吃饭,中午 的时候,饿得不行 了,出去找吃的。 这时候,吃东西就是一种算法,你可以...

FBB360JAVA的博客 2216

VisionPro开发实战:CogRecordDisplay控件显示与保存图片的完整流程(附C#代码示例)

本文详细解析了VisionPro开发中CogRecordDisplay控件的图像处理全流程,包括图像加载、显示优化、动态清屏及结果保存等关键操作。通过C#代码示例,展示了如何高效使用该控件进行工业视觉应用开发,特别适合自动化检测系统的开发者参考。

weixin_42523792的博客 283

HyperLynx(三十一)高速串行总线仿真(三)

(5)选择 “File”→ “Open Touchstone”,打开路径 C:\Adv_HL_Tmg\SERDES_Interface\models,选中connector.s4p,单击打开,如图所示。接下来,找出将要分配模型的S参数连接。(12)单击“Assign”按钮,选择模型类型为“Touchstone models”,在库中选择“connector.s4p”,如图所示。(14)单击“OK”按钮,选中“connector.s4p”这一行,单击“Connection Editor”按钮,如图所示。

小幽余生不加糖 3374

策略模式和排序算法

引言常用的排序算法有选择排序,插入排序,冒泡排序,快速排序,归并排序,希尔排序,堆排序这7种。假设现在有7个数组,他们分别需要用到这7种排序方式的其中一个进行排序应该怎么办呢。最常见的办法就是写一个这样的工具类/** * Created by hao on 2016/6/19. */ public class SortHelper { /** * 选择排序 * @pa

haozhn的博客 1948

《大数据: Hive 交互命令和常用配置》

一、Hive 交互命令 1. 首先解决一个可能发生的问题 (log4 jar包冲突) 我这里解决方法就是删除一个,我删的是hive下的包 yexiang@hadoop1:<hive>$ hive SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/soft/apache-hive-2.3.7-bin/lib/log4j-slf4j-impl-2.6.2.ja.

yexiangCSDN的专栏 293

从两个排序算法实现c++策略模式

简介 所谓策略,是指一系列的操作。 比如古代打仗,可以直接双方对垒派兵厮打,也可以等到月明星稀偷营劫寨,还可以略施小计。这些都是策略。 又比如计算税费时,不同国家的计算方法是不同的。如美国的10%,日本的8%,欧萌的12%…等,这些也都是策略。 策略模式,就是把一个个的策略封装起来,并且使它们可以相互替换。以达到算法独立于客户的目的。这样可以在不改变客户的情况下灵活地变更各种策略(算法)。 策略模式的目的就是为了适应不同的需求,把这些容易变化的点(不同策略之间可能会互换)封装起来。这样就能够在不变更原有代

guotianqing的博客 304

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

JAVA--基于策略模式几种排序算法的实现

进来学习了设计模式,这里使用策略模式来组织多种排序算法。 首先我们定义一个抽象类,OrderBase,数据的输入,展示部分在抽象类里实现,具体的排序逻辑在各个子类里实现。     为什么用抽象类不用接口?接口里只有函数的定义,不能有实现。使用抽象类,可以实现公共函数,定义抽象函数。(父类和子类就是一个从一般到特殊的过程) OrderBase.java public abstract ...

qq_20694641的博客 1932

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

C++ 策略模式调用不同的排序算法

前些天学过策略模式,最近重温了几种常用的简单排序算法,想到了策略模式,就实际操练一下。 Sort.h #pragma once #include&amp;amp;amp;lt;iostream&amp;amp;amp;gt; using namespace std; class Sort { public: virtual void sortSeq(int a[], int n) = 0; }; class BobbleSort :publ...

weixin_42333471的博客 978

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

策略模式-排序算法

[关键字]:java,design pattern,设计模式,《Java与模式》学习,Strategy Pattern,策略模式 [环境]:StarUML5.0 + JDK6 [作者]:Winty (wintys@gmail.com) http://www.blogjava.net/wintys/ [正文]: 策略模式:排序算法 package pattern.strategy....

天堂露珠 的专栏 558

策略模式的实现,排序算法分析

策略模式的实现,排序算法分析1. 初步了解设计模式的意义。2. 能够根据策略模式模型,设计类。1.利用JavaFX设计简单的用户交互界面,允许从文件读入不少于100个数据,并对这些数据排序(可以是数字、字符串等内容)。2.提供至少三种排序算法(直接插入排序、冒泡排序、归并排序)3.可以选择数据文件,文件中至少应包含100条以上的数据。4.下拉框可以选择排序方法,运行后获得排序结果,并按照排序写入结果文件(三个算法分别建立排序结果文件,以便答辩时检查排序准确性)。

m0_60434562的博客 236

[设计模式]策略模式(Strategy Pattern)的应用与实践(实例:支付系统、排序算法、会员折扣系统)

策略模式是一种行为设计模式,它通过定义算法家族并封装每个算法,使它们可以相互替换。该模式包含三个核心组件:策略接口定义算法规范,具体策略类实现不同算法,上下文类维护策略引用并执行算法。策略模式的优点包括消除条件语句、支持运行时切换算法、易于扩展新策略,符合开闭原则。典型应用场景包括支付系统、排序算法、会员折扣等。该模式可以与工厂模式、Lambda表达式或枚举结合使用,但需注意策略类增多和客户端需了解策略差异等问题。实际应用中应考虑策略选择机制、状态共享和性能优化等因素。

y8313568的专栏 383

JDP02-[策略模式]-多种排序算法

一)  策略模式简介       策略模式的结构图如下所示:           二)  Java语言描述       用策略模式实现各种排序算法的调用:   /* * 策略模式(策略构件) * @author junin */ public class Strategy { private StrategyInter strat...

junife的专栏 320

使用工厂方法模式和策略模式封装常用排序算法

使用工厂方法模式和策略模式封装冒泡排序,选择排序,插入排序,快速排序,堆排序,希尔排序,归并排序七个常用排序算法,代码已经上机测试并运行通过。

虚心求学 684

数据结构---排序算法(策略模式)

策略模式,以排序为例:    interface Strategy    {        void Sort(List list);    }    class QuickSortStrategy : Strategy    {        //快速排序        public void Sort(List list)        {            list.Sort()

yxqznkl2009的专栏 382

策略模式+简单工厂使用排序算法(c++实现)

#include<iostream> #include<vector> #include<string> using namespace std; //抽象排序算法 //当成strategy来使用 class AbstractSort { private: vector<int> nums; public: AbstractSort(vector<int> _nums) { this->nums = _nums; } A.

Emotion的博客 282

你知道怎么在排序算法中使用策略模式吗?

抽点时间简单回顾下八大排序算法中的冒泡 。。毕竟其他也记不住 哈哈哈哈 使用策略模式来实现,策略模式使用范围也很广,如省略一堆 if else 一般用在。。额 等找到笔记再补上 一。定义一个抽象类 /** * 之所以定义成 抽象类 而不是接口 只是为了少写点代码,加入name 属性 哈哈哈 */ abstract class SortStrategy { String name; abstract int[] sortArr(int[] arr); String getN

公众号 Java4ye 378
上一篇: 简单工厂、工厂方法和抽象工厂的区别
下一篇: 代理模式
hp_cpp
博客等级 码龄11年 310粉丝 218原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址