Re: overload operator < 來排序
自問自答一下
現在想到的是說 如果在要排序的objecet中定義個static 的pointer
指到要指的string 這樣應該就可以有資訊來排index..
但我現在希望的是在要排的ojbect中有個function pointer指到
比較大小的函數, 而這個函數並不能馬上決定, 需要可以抽換
要用到的info的type也不能決定 這樣有辦法嗎
※ 引述《sorryChen》之銘言:
: 網路有C++的例子說 如果要排序一個objects array
: 可以自己定義比較的函數 或overload operator
: 然後利用<algorithm> 中的sort或binary search.
: 我的問題是.. 如果我要排序是一個string的index.
: 所以比較大小的時候 必須根據其他存在array外的資訊
: 其實是要去查存在array中string index 相對的substring的字典順序
: (有點像surffix array)
: 這樣還有辦法寫一個比較的operator嗎?
: ※ 編輯: sorryChen 來自: 128.125.87.33 (04/03 00:35)
: ※ 編輯: sorryChen 來自: 128.125.87.33 (04/03 00:45)
: ※ 編輯: sorryChen 來自: 128.125.87.33 (04/03 00:46)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 128.125.87.33
※ 編輯: sorryChen 來自: 128.125.87.33 (04/03 01:30)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 9 篇):