文字MD5クイックの検索

// 分類 
CONST tagMap = {
}。

関数findTag(S){
    聞かせてPOS = 1 ;
    タグせ = s.substr(0 、POS)は、
    一方、(tagMap [タグ]){
        POS ++ ;
        タグ = s.substr(0 、POS)。
    }

    リターン POS-1 ;
}

機能セット(S1、コールバック){

    CONST POS = findTag(S1)。
    CONSTタグ = s1.substr(0 、POS)。
    CONST D = S1 [POS]。

    CONST ARR = tagMap [タグ]。
    もし(ARR){
         場合(arr.indexOf(s1.substr(POS))=== - 1 ){
            ARR1 CONST = []
            CONST ARR2 = []
            arr.forEach(関数(STR){
                 もし === [0] STR(D){
                    arr2.push(str.substr( 1 ))
                } {
                    arr1.push(STR)
                }
            })
            もし(=== 0 arr2.length {)
                tagMap [タグ] .push(s1.substr(POS))。
            } {
                TAGMAP [タグ] = ARR1。
                (s1.substr(POS arr2.push 1 ))
                tagMap [タグ +のD] = ARR2。
            }

        } {

        }

    } {
        TAGMAP [タグ] = []
        tagMap [タグ] .push(s1.substr(POS))。
    }

}

セット( '552cb8e71eea229fd1ea8ac0010057e6' 
セット( '552cb8e71eea229fd1ea8ac0010057e6' 
セット( '542cb8e71eea229fd1ea8ac0010057e6' 
セット( '532cb8e71eea229fd1ea8ac0010057e6' 
セット( '522cb8e71eea229fd1ea8ac0010057e6' 
セット( '512cb8e71eea229fd1ea8ac0010057e6' 

console.log(tagMap)

 

おすすめ

転載: www.cnblogs.com/caoke/p/11902123.html