本文整理匯總了Golang中github.com/openshift/origin/pkg/security/mcs.Range類的典型用法代碼示例。如果您正苦於以下問題:Golang Range類的具體用法?Golang Range怎麽用?Golang Range使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Range類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Restore
// Restore restores the pool to the previously captured state. ErrMismatchedNetwork
// is returned if the provided port range doesn't exactly match the previous range.
func (r *Allocator) Restore(into *mcs.Range, data []byte) error {
if into.String() != r.r.String() {
return ErrMismatchedRange
}
snapshottable, ok := r.alloc.(allocator.Snapshottable)
if !ok {
return fmt.Errorf("not a snapshottable allocator")
}
return snapshottable.Restore(into.String(), data)
}
示例2: DefaultMCSAllocation
// DefaultMCSAllocation returns a label from the MCS range that matches the offset
// within the overall range. blockSize must be a positive integer representing the
// number of labels to jump past in the category space (if 1, range == label, if 2
// each range will have two labels).
func DefaultMCSAllocation(from *uid.Range, to *mcs.Range, blockSize int) MCSAllocationFunc {
return func(block uid.Block) *mcs.Label {
ok, offset := from.Offset(block)
if !ok {
return nil
}
if blockSize > 0 {
offset = offset * uint32(blockSize)
}
label, _ := to.LabelAt(uint64(offset))
return label
}
}
示例3: New
// New creates a Allocator over a UID range, calling factory to construct the backing store.
func New(r *mcs.Range, factory allocator.AllocatorFactory) *Allocator {
return &Allocator{
r: r,
alloc: factory(int(r.Size()), r.String()),
}
}