Files
swift-mirror/stdlib/public/core/Slice.swift
Dmitri Hrybenko be5ef02bd0 Revert "stdlib: make Slice.init(base:bounds:) public"
This reverts commit 30111.  It broke the buildbots.

Swift SVN r30112
2015-07-11 05:34:05 +00:00

36 lines
1.0 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
public struct Slice<Base : Indexable> : CollectionType {
public typealias Index = Base.Index
public let startIndex: Index
public let endIndex: Index
public subscript(index: Index) -> Base._Element {
return _base[index]
}
public subscript(bounds: Range<Index>) -> Slice {
return Slice(_base: _base, bounds: bounds)
}
internal init(_base: Base, bounds: Range<Index>) {
self._base = _base
self.startIndex = bounds.startIndex
self.endIndex = bounds.endIndex
}
internal let _base: Base
}