Giter VIP home page Giter VIP logo

sort-algorithm's Introduction

sort-algorithm

你可以使用自定義的資料結構,透過呼叫sort-algorithm進行排序(支援quick、merge、insertion sort)。

Example code

main.cpp是示範如何使用sort_alg.h。

在呼叫sort前,你需要先執行以下步驟

1. Implement compare function

如以下:

cmp

Obj為自定義的資料結構,cmp為compare function,你需要實作compare function,比較兩個Object:A與B,

若A比B小,return -1,若A與B相等,return 0,若A比B大,return 1

2. Define function pointer

ptr

定義一個function pointer,並指向compare function

3. Create sort object and call sort

obj

參數依序為:list,front,end,cmp_ptr

list可為array、vector,若是一個int array,如int list[20]; 則front為0,end為19

sort-algorithm's People

Contributors

as200188 avatar

Watchers

 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.