pub( crate ) mod private
{
use crate::prelude::*;
use wtools::prelude::*;
use indexmap::IndexSet;
use core::fmt;
pub struct Node< NodeId = crate::IdentityWithInt, EdgeId = crate::IdentityWithInt, Kind = crate::NodeKindless >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
{
pub out_nodes : IndexSet< NodeId >,
pub out_edges : IndexSet< EdgeId >,
pub kind : Kind,
pub id : NodeId,
}
impl< NodeId, EdgeId, Kind > Node< NodeId, EdgeId, Kind >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
{
pub fn make_with_id< Name >( id : Name ) ->Self
where
Name : Into< < Self as HasId >::Id >,
{
let out_nodes = IndexSet::new();
let out_edges = IndexSet::new();
let kind = Default::default();
Self
{
out_nodes,
out_edges,
kind,
id : id.into(),
}
}
}
impl< NodeId, EdgeId, Kind, IntoId > Make1< IntoId >
for Node< NodeId, EdgeId, Kind >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
IntoId : Into< < Self as HasId >::Id >,
{
fn make_1( id : IntoId ) -> Self
{
Self::make_with_id( id )
}
}
impl< NodeId, EdgeId, Kind > HasId
for Node< NodeId, EdgeId, Kind >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
{
type Id = NodeId;
fn id( &self ) -> Self::Id
{
self.id
}
}
impl< NodeId, EdgeId, Kind > NodeBasicInterface
for Node< NodeId, EdgeId, Kind >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
{
}
impl< NodeId, EdgeId, Kind > fmt::Debug
for Node< NodeId, EdgeId, Kind >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
{
fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result
{
f.write_fmt( format_args!( "node::{:?}", self.id() ) )?;
for e in &self.out_nodes
{
f.write_fmt( format_args!( "\n - {:?}", e ) )?;
}
f.write_fmt( format_args!( "" ) )
}
}
impl< NodeId, EdgeId, Kind > PartialEq
for Node< NodeId, EdgeId, Kind >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
{
fn eq( &self, other : &Self ) -> bool
{
self.id() == other.id()
}
}
impl< NodeId, EdgeId, Kind > Eq
for Node< NodeId, EdgeId, Kind >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
Kind : NodeKindInterface,
{}
}
pub mod protected
{
pub use super::orphan::*;
}
pub use protected::*;
pub mod orphan
{
pub use super::exposed::*;
pub use super::private::{ Node };
}
pub mod exposed
{
pub use super::prelude::*;
}
pub mod prelude
{
}