Generic Structure

ManagedBufferPointer

Contains a buffer object, and provides access to an instance of Header and contiguous storage for an arbitrary number of Element instances stored in that buffer. バッファオブジェクトを収容します、そしてHeaderのインスタンスへのアクセスおよびそのバッファに格納される随意の数のElementインスタンスの隣接保管を提供します。

Declaration 宣言

@frozen struct ManagedBufferPointer<Header, Element>

Overview 概要

For most purposes, the ManagedBuffer class can be used on its own. However, in cases where objects of various different classes must serve as storage, you need to also use ManagedBufferPointer.

A valid buffer class is non-@objc, with no declared stored properties. Its deinit must destroy its stored Header and any constructed Elements. 有効なバッファクラスは、非@objcで、宣言された保存プロパティを持ちません。それのdeinitは、それの格納されたHeaderとあらゆる構成されたElementを破棄しなければなりません。

Example Buffer Class バッファクラスの例


 class MyBuffer<Element> { // non-@objc
   typealias Manager = ManagedBufferPointer<(Int, String), Element>
   deinit {
     Manager(unsafeBufferObject: self).withUnsafeMutablePointers {
       (pointerToHeader, pointerToElements) -> Void in
       pointerToElements.deinitialize(count: self.count)
       pointerToHeader.deinitialize(count: 1)
     }
   }


   // All properties are *computed* based on members of the Header
   var count: Int {
     return Manager(unsafeBufferObject: self).header.0
   }
   var name: String {
     return Manager(unsafeBufferObject: self).header.1
   }
 }

Topics 話題

Creating a Buffer バッファの作成

Inspecting a Buffer バッファを調査する

Accessing Buffer Contents バッファ内容にアクセスする

Comparing Buffers バッファの比較

Operator Functions 演算子関数

Relationships 関係

Conforms To 次に準拠

See Also 参照

Buffer Implementation Buffer 実装