@@ -19,12 +19,12 @@ use crate::bit::{
1919 BitLocations , ClassicalRegister , PyBit , QuantumRegister , Register , ShareableClbit ,
2020 ShareableQubit ,
2121} ;
22- use crate :: bit_data:: BitData ;
2322use crate :: bit_locator:: BitLocator ;
2423use crate :: circuit_instruction:: { CircuitInstruction , OperationFromPython } ;
2524use crate :: dag_circuit:: add_global_phase;
2625use crate :: imports:: { ANNOTATED_OPERATION , QUANTUM_CIRCUIT } ;
2726use crate :: interner:: { Interned , Interner } ;
27+ use crate :: object_registry:: ObjectRegistry ;
2828use crate :: operations:: { Operation , OperationRef , Param , StandardGate } ;
2929use crate :: packed_instruction:: { PackedInstruction , PackedOperation } ;
3030use crate :: parameter_table:: { ParameterTable , ParameterTableError , ParameterUse , ParameterUuid } ;
@@ -116,9 +116,9 @@ pub struct CircuitData {
116116 /// The cache used to intern instruction bits.
117117 cargs_interner : Interner < [ Clbit ] > ,
118118 /// Qubits registered in the circuit.
119- qubits : BitData < Qubit , ShareableQubit > ,
119+ qubits : ObjectRegistry < Qubit , ShareableQubit > ,
120120 /// Clbits registered in the circuit.
121- clbits : BitData < Clbit , ShareableClbit > ,
121+ clbits : ObjectRegistry < Clbit , ShareableClbit > ,
122122 /// QuantumRegisters stored in the circuit
123123 qregs : RegisterData < QuantumRegister > ,
124124 /// ClassicalRegisters stored in the circuit
@@ -150,8 +150,8 @@ impl CircuitData {
150150 data : Vec :: new ( ) ,
151151 qargs_interner : Interner :: new ( ) ,
152152 cargs_interner : Interner :: new ( ) ,
153- qubits : BitData :: new ( ) ,
154- clbits : BitData :: new ( ) ,
153+ qubits : ObjectRegistry :: new ( ) ,
154+ clbits : ObjectRegistry :: new ( ) ,
155155 param_table : ParameterTable :: new ( ) ,
156156 global_phase : Param :: Float ( 0. ) ,
157157 qregs : RegisterData :: new ( ) ,
@@ -182,8 +182,8 @@ impl CircuitData {
182182 let args = {
183183 let self_ = self_. borrow ( ) ;
184184 (
185- ( !self_. qubits . is_empty ( ) ) . then_some ( self_. qubits . bits ( ) . clone ( ) ) ,
186- ( !self_. clbits . is_empty ( ) ) . then_some ( self_. clbits . bits ( ) . clone ( ) ) ,
185+ ( !self_. qubits . is_empty ( ) ) . then_some ( self_. qubits . objects ( ) . clone ( ) ) ,
186+ ( !self_. clbits . is_empty ( ) ) . then_some ( self_. clbits . objects ( ) . clone ( ) ) ,
187187 None :: < ( ) > ,
188188 self_. data . len ( ) ,
189189 self_. global_phase . clone ( ) ,
@@ -247,7 +247,7 @@ impl CircuitData {
247247 self . add_qreg ( register, true ) ?;
248248 }
249249
250- for ( index, qubit) in self . qubits . bits ( ) . iter ( ) . enumerate ( ) {
250+ for ( index, qubit) in self . qubits . objects ( ) . iter ( ) . enumerate ( ) {
251251 if !self . qubit_indices . contains_key ( qubit) {
252252 self . qubit_indices
253253 . insert ( qubit. clone ( ) , BitLocations :: new ( index as u32 , [ ] ) ) ;
@@ -308,7 +308,7 @@ impl CircuitData {
308308 self . add_creg ( register, true ) ?;
309309 }
310310
311- for ( index, clbit) in self . clbits . bits ( ) . iter ( ) . enumerate ( ) {
311+ for ( index, clbit) in self . clbits . objects ( ) . iter ( ) . enumerate ( ) {
312312 if !self . clbit_indices . contains_key ( clbit) {
313313 self . clbit_indices
314314 . insert ( clbit. clone ( ) , BitLocations :: new ( index as u32 , [ ] ) ) ;
@@ -533,8 +533,8 @@ impl CircuitData {
533533 pub fn copy_empty_like ( & self , py : Python < ' _ > ) -> PyResult < Self > {
534534 let mut res = CircuitData :: new (
535535 py,
536- Some ( self . qubits . bits ( ) . clone ( ) ) ,
537- Some ( self . clbits . bits ( ) . clone ( ) ) ,
536+ Some ( self . qubits . objects ( ) . clone ( ) ) ,
537+ Some ( self . clbits . objects ( ) . clone ( ) ) ,
538538 None ,
539539 0 ,
540540 self . global_phase . clone ( ) ,
@@ -1159,7 +1159,7 @@ impl CircuitData {
11591159 ) -> PyResult < Vec < ShareableQubit > > {
11601160 bit_argument_conversion (
11611161 & qubit_representation,
1162- self . qubits . bits ( ) ,
1162+ self . qubits . objects ( ) ,
11631163 & self . qubit_indices ,
11641164 )
11651165 }
@@ -1178,7 +1178,7 @@ impl CircuitData {
11781178 ) -> PyResult < Vec < ShareableClbit > > {
11791179 bit_argument_conversion (
11801180 & clbit_representation,
1181- self . clbits . bits ( ) ,
1181+ self . clbits . objects ( ) ,
11821182 & self . clbit_indices ,
11831183 )
11841184 }
@@ -1294,8 +1294,8 @@ impl CircuitData {
12941294 #[ allow( clippy:: too_many_arguments) ]
12951295 pub fn from_packed_instructions < I > (
12961296 py : Python ,
1297- qubits : BitData < Qubit , ShareableQubit > ,
1298- clbits : BitData < Clbit , ShareableClbit > ,
1297+ qubits : ObjectRegistry < Qubit , ShareableQubit > ,
1298+ clbits : ObjectRegistry < Clbit , ShareableClbit > ,
12991299 qargs_interner : Interner < [ Qubit ] > ,
13001300 cargs_interner : Interner < [ Clbit ] > ,
13011301 qregs : RegisterData < QuantumRegister > ,
@@ -1399,8 +1399,8 @@ impl CircuitData {
13991399 data : Vec :: with_capacity ( instruction_capacity) ,
14001400 qargs_interner : Interner :: new ( ) ,
14011401 cargs_interner : Interner :: new ( ) ,
1402- qubits : BitData :: with_capacity ( num_qubits as usize ) ,
1403- clbits : BitData :: with_capacity ( num_clbits as usize ) ,
1402+ qubits : ObjectRegistry :: with_capacity ( num_qubits as usize ) ,
1403+ clbits : ObjectRegistry :: with_capacity ( num_clbits as usize ) ,
14041404 param_table : ParameterTable :: new ( ) ,
14051405 global_phase : Param :: Float ( 0.0 ) ,
14061406 qregs : RegisterData :: new ( ) ,
@@ -1553,12 +1553,12 @@ impl CircuitData {
15531553 fn pack ( & mut self , py : Python , inst : & CircuitInstruction ) -> PyResult < PackedInstruction > {
15541554 let qubits = self . qargs_interner . insert_owned (
15551555 self . qubits
1556- . map_bits ( inst. qubits . extract :: < Vec < ShareableQubit > > ( py) ?. into_iter ( ) ) ?
1556+ . map_objects ( inst. qubits . extract :: < Vec < ShareableQubit > > ( py) ?. into_iter ( ) ) ?
15571557 . collect ( ) ,
15581558 ) ;
15591559 let clbits = self . cargs_interner . insert_owned (
15601560 self . clbits
1561- . map_bits ( inst. clbits . extract :: < Vec < ShareableClbit > > ( py) ?. into_iter ( ) ) ?
1561+ . map_objects ( inst. clbits . extract :: < Vec < ShareableClbit > > ( py) ?. into_iter ( ) ) ?
15621562 . collect ( ) ,
15631563 ) ;
15641564 Ok ( PackedInstruction {
@@ -1637,12 +1637,12 @@ impl CircuitData {
16371637 }
16381638
16391639 /// Returns an immutable view of the Qubits registered in the circuit
1640- pub fn qubits ( & self ) -> & BitData < Qubit , ShareableQubit > {
1640+ pub fn qubits ( & self ) -> & ObjectRegistry < Qubit , ShareableQubit > {
16411641 & self . qubits
16421642 }
16431643
16441644 /// Returns an immutable view of the Classical bits registered in the circuit
1645- pub fn clbits ( & self ) -> & BitData < Clbit , ShareableClbit > {
1645+ pub fn clbits ( & self ) -> & ObjectRegistry < Clbit , ShareableClbit > {
16461646 & self . clbits
16471647 }
16481648
0 commit comments