コード例 #1
0
int main()
{
  typedef rt::node_allocator_lazy<int> inner_alloc_type;
  typedef std::list<int, inner_alloc_type> inner_list_type;

  typedef std::scoped_allocator_adaptor< rt::node_allocator_lazy<inner_list_type>
                                       , inner_alloc_type> outer_alloc_type;
  typedef std::list<inner_list_type, outer_alloc_type> outer_list_type;

  std::array<char, 2000> buffer1 = {{}};
  std::array<char, 2000> buffer2 = {{}};
  rt::node_alloc_header header1(buffer1);
  rt::node_alloc_header header2(buffer2);

  inner_alloc_type alloc1(&header1);
  rt::node_allocator_lazy<inner_list_type> alloc2(&header2);

  outer_alloc_type alloc(alloc2, alloc1);

  outer_list_type t1(alloc);

  t1.push_back({{5, 3, 7, 20}, alloc1});
  t1.push_back({{1, 44, 22, 8}, alloc1});

  rt::print(t1.front());
  rt::print(t1.back());
}
コード例 #2
0
 //! <b>Requires</b>: node1 and node2 can't be header nodes
 //!  of two trees.
 //! 
 //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted
 //!   in the position node2 before the function. node2 will be inserted in the
 //!   position node1 had before the function.
 //! 
 //! <b>Complexity</b>: Logarithmic. 
 //! 
 //! <b>Throws</b>: Nothing.
 //! 
 //! <b>Note</b>: This function will break container ordering invariants if
 //!   node1 and node2 are not equivalent according to the ordering rules.
 //!
 //!Experimental function
 static void swap_nodes(node_ptr node1, node_ptr node2)
 {
    if(node1 == node2)
       return;
 
    node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2));
    swap_nodes(node1, header1, node2, header2);
 }
コード例 #3
0
ファイル: cql_header.cpp プロジェクト: sonneym/libcql
TEST(cql_header_cpp, serialization_round_trip)
{
    std::stringstream output;
    cql::internal::cql_header_t header1(CQL_VERSION_1_REQUEST, CQL_FLAG_NOFLAG, 1, CQL_OPCODE_READY, 5);
    cql::internal::cql_header_t header2;
    header1.write(output);
    header2.read(output);
    EXPECT_EQ(header1.version(), header2.version());
    EXPECT_EQ(header1.flags(), header2.flags());
    EXPECT_EQ(header1.stream(), header2.stream());
    EXPECT_EQ(header1.opcode(), header2.opcode());
    EXPECT_EQ(header1.size(), header2.size());
}
コード例 #4
0
ファイル: msh_header.c プロジェクト: Ngoguey42/proj08_unix_sh
void		msh_header(void)
{
	int	i;

	i = 0;
	while (i < 7 * 6)
	{
		if (i % 7 < 4)
			header1(i / 7 * 4 + i % 7);
		else
			header2(i / 7 * 3 + i % 7 - 4);
		i++;
	}
	return ;
}
コード例 #5
0
ファイル: NtpTest.cpp プロジェクト: jimmiebergmann/Bit-Test
// Virtual functions
void NtpTest::Run( std::ostream & p_Trace )
{
	std::cout << "-------------------------------------------" << std::endl;
	std::cout << "Starting NTP test." << std::endl;

	// Open a ntp client
	Bit::Ntp ntp( 0, 123 );

	// Assert a ntp header
	Bit::Ntp::Header header1( Bit::Ntp::Header::NoWarning, 4, Bit::Ntp::Header::Client );
	TestAssert( header1.GetLeapIndicator( ) == Bit::Ntp::Header::NoWarning );
	TestAssert( header1.GetVersion( ) == 4 );
	TestAssert( header1.GetMode( ) == Bit::Ntp::Header::Client );

	// Assert the ntp set and get functions
	Bit::Ntp::Header header2;
	header2.SetLeapIndicator( Bit::Ntp::Header::Remove );
	header2.SetVersion( 5 );
	header2.SetMode( Bit::Ntp::Header::Server );
	TestAssert( header2.GetLeapIndicator( ) == Bit::Ntp::Header::Remove );
	TestAssert( header2.GetVersion( ) == 5 );
	TestAssert( header2.GetMode( ) == Bit::Ntp::Header::Server );

	// Send request to NTP server
	Bit::Address serverAddress( "0.europe.pool.ntp.org" );
	ntp.SendRequest( header1, serverAddress );
	std::cout << "Sent request." << std::endl;

	// Assert Receive response from NTP server
	Bit::Ntp::Header header3( Bit::Ntp::Header::NoWarning, 4, Bit::Ntp::Header::Client );
	TestAssert( ntp.ReceiveResponse( header3, serverAddress ) == true );
	std::cout << "Received response:" << std::endl;

	// Print the response
	std::cout << " Leap: "				<< (Bit::Uint32)header3.GetLeapIndicator( ) << std::endl;
	std::cout << " Version: "			<< (Bit::Uint32)header3.GetVersion( ) << std::endl;
	std::cout << " Mode: "				<< (Bit::Uint32)header3.GetMode( ) << std::endl;
	std::cout << " Stratum: "			<< (Bit::Uint32)header3.GetStratum( ) << std::endl;
	std::cout << " Polling interval: "	<< (Bit::Uint32)header3.GetPollInterval( ) << std::endl;
	std::cout << " Precision: "			<< (Bit::Uint32)header3.GetPrecision( ) << std::endl;
	std::cout << " Root delay: "		<< header3.GetRootDelay( ) << std::endl;
	std::cout << " Root dispersion: "	<< header3.GetRootDispersion( ) << std::endl;
	Bit::Address address( header3.GetReferenceClock( ) );
	std::cout << " Referense address: "	<< (int)address.GetA( ) << "."
								<< (int)address.GetB( ) << "."
								<< (int)address.GetC( ) << "."
								<< (int)address.GetD( ) << std::endl;
	std::cout << std::endl;
	std::cout	<< " Reference time       : " << header3.GetReferenceTimestamp( ).GetTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetReferenceTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << " Reference local time : " << header3.GetTransmitTimestamp( ).GetLocalTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetReferenceTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << std::endl;
	std::cout << " Origin time       : " << header3.GetOriginateTimestamp( ).GetTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetOriginateTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << " Origin local time : " << header3.GetOriginateTimestamp( ).GetLocalTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetOriginateTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << std::endl;
	std::cout << " Receive time       : " << header3.GetReceiveTimestamp( ).GetTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetReceiveTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << " Receive local time : " << header3.GetReceiveTimestamp( ).GetLocalTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetReceiveTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << std::endl;
	std::cout << " Transmit time       : " << header3.GetTransmitTimestamp( ).GetTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetTransmitTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << " Transmit local time : " << header3.GetTransmitTimestamp( ).GetLocalTimeString( )
				<< " ("	<< static_cast<Bit::Float64>( header3.GetTransmitTimestamp( ).GetFractions( ) ) / static_cast<Bit::Float64>( 0xFFFFFFFF ) <<  ")"  << std::endl;
	std::cout << std::endl;
	

	// Close the ntp client
	ntp.Close( );
	
	// Print the finish text
	std::cout << "Finished NTP Test." << std::endl;
	std::cout << "-------------------------------------------" << std::endl;
	
}