github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/text/collate/colltab/export.go (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package colltab 6 7 // Init is for internal use only. 8 func Init(data interface{}) Weighter { 9 init, ok := data.(tableInitializer) 10 if !ok { 11 return nil 12 } 13 t := &table{} 14 loff, voff := init.FirstBlockOffsets() 15 t.index.index = init.TrieIndex() 16 t.index.index0 = t.index.index[blockSize*int(loff):] 17 t.index.values = init.TrieValues() 18 t.index.values0 = t.index.values[blockSize*int(voff):] 19 t.expandElem = init.ExpandElems() 20 t.contractTries = init.ContractTries() 21 t.contractElem = init.ContractElems() 22 t.maxContractLen = init.MaxContractLen() 23 t.variableTop = init.VariableTop() 24 return t 25 } 26 27 type tableInitializer interface { 28 TrieIndex() []uint16 29 TrieValues() []uint32 30 FirstBlockOffsets() (lookup, value uint16) 31 ExpandElems() []uint32 32 ContractTries() []struct{ l, h, n, i uint8 } 33 ContractElems() []uint32 34 MaxContractLen() int 35 VariableTop() uint32 36 }