Coder Social home page Coder Social logo

versioncompare's Introduction

versionCompare

版本比较

两个版本进行比较时需要考虑较多的因素

下面是我们程序的运行结果

version:1.2.3	 version 1.2.3  	compare result:0
version:1.2.3	 version 1.2.3a 	compare result:-1
version:1.2.3b	 version 1.2.3a 	compare result:1
version:1.2.a	 version: 1.2.3 	compare result:-3
version:1.2.3	 version: 1.2.3a	compare result:-1
version:[d]	 version: 1.2.3  	compare result:-2
version:1.2.3	 version: 1.12.3  	compare result:-1
version:1.a12b.3	 version: 1.a123b.3  	compare result:-1
version:1.ab1b.3	 version: 1.a123b.3  	compare result:1

/比较版本大小的思路/

  1. split 将对应的字符串风分割开,相同类型的字符作为同一个字符串 如 1.1.1 分割为 1 . 1 . 1 如 1.11.1 分割为 1 . 11 . 1 如 1.a11ab.1 分割为 1 . a 11 ab . 1
  2. 将分割开的字符串进行比较 比较分为字符串的比较和数字的比较 1 11 比较 a ab 比较
  3. 根据比较的结果返回对应的比较结果

考虑上方的异常情况

versioncompare's People

Contributors

tomsms avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.