AtomStateData

Struct AtomStateData 

Source
pub struct AtomStateData {
    pub locations_to_qubit: HashMap<LocationAddr, u32>,
    pub qubit_to_locations: HashMap<u32, LocationAddr>,
    pub collision: HashMap<u32, u32>,
    pub prev_lanes: HashMap<u32, LaneAddr>,
    pub move_count: HashMap<u32, u32>,
}
Expand description

Tracks qubit-to-location mappings as atoms move through the architecture.

This is an immutable value type: all mutation methods (add_atoms, apply_moves) return a new instance rather than modifying in place.

The two primary maps (locations_to_qubit and qubit_to_locations) are kept in sync as a bidirectional index. When a move causes two atoms to occupy the same site, both are removed from the location maps and recorded in collision.

Fields§

§locations_to_qubit: HashMap<LocationAddr, u32>

Reverse index: given a physical location, which qubit (if any) is there?

§qubit_to_locations: HashMap<u32, LocationAddr>

Forward index: given a qubit id, where is it currently located?

§collision: HashMap<u32, u32>

Cumulative record of qubits that have collided since this state was created (via constructors or add_atoms). Updated by apply_moves — new collisions are added to existing entries. Key is the moving qubit, value is the qubit it displaced. Collided qubits are removed from both location maps.

§prev_lanes: HashMap<u32, LaneAddr>

The lane each qubit used in the most recent apply_moves. Only populated for qubits that moved in the last step.

§move_count: HashMap<u32, u32>

Cumulative number of moves each qubit has undergone across all apply_moves calls in the state’s history.

Implementations§

Source§

impl AtomStateData

Source

pub fn new() -> Self

Create an empty state with no qubits or locations.

Source

pub fn from_locations(locations: &[(u32, LocationAddr)]) -> Self

Create a state from a list of (qubit_id, location) pairs.

Builds both the forward (qubit → location) and reverse (location → qubit) maps. All other fields (collision, prev_lanes, move_count) are empty.

Source

pub fn add_atoms( &self, locations: &[(u32, LocationAddr)], ) -> Result<Self, &'static str>

Add atoms at new locations, returning a new state.

Each (qubit_id, location) pair is added to the bidirectional maps. Returns Err if any qubit id already exists in this state or any location is already occupied by another qubit.

The returned state inherits no collision, prev_lanes, or move_count data — those fields are reset to empty.

Source

pub fn apply_moves( &self, lanes: &[LaneAddr], arch_spec: &ArchSpec, ) -> Option<Self>

Apply a sequence of lane moves and return the resulting state.

For each lane, resolves its source and destination locations via ArchSpec::lane_endpoints. If a qubit exists at the source, it is moved to the destination. If the destination is already occupied, both qubits are removed from the location maps and recorded in collision. Lanes whose source has no qubit are skipped.

Returns None if any lane cannot be resolved to endpoints (invalid bus, word, or site). The prev_lanes field is reset to contain only the lanes used in this call; move_count is accumulated.

Source

pub fn get_qubit(&self, location: &LocationAddr) -> Option<u32>

Look up which qubit (if any) occupies the given location.

Source

pub fn get_qubit_pairing( &self, zone: &ZoneAddr, arch_spec: &ArchSpec, ) -> Option<(Vec<u32>, Vec<u32>, Vec<u32>)>

Find CZ gate control/target qubit pairings within a zone.

Iterates over all qubits whose current location is in the given zone and checks whether the CZ pair site (via ArchSpec::get_blockaded_location) is also occupied. If both sites are occupied, the qubits form a control/target pair. If the pair site is empty or doesn’t exist, the qubit is unpaired.

Returns (controls, targets, unpaired) where controls[i] and targets[i] are paired for CZ. Results are sorted by qubit id for deterministic ordering. Returns None if the zone id is invalid.

Trait Implementations§

Source§

impl Clone for AtomStateData

Source§

fn clone(&self) -> AtomStateData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AtomStateData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AtomStateData

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Hash for AtomStateData

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for AtomStateData

Source§

fn eq(&self, other: &AtomStateData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for AtomStateData

Source§

impl StructuralPartialEq for AtomStateData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.