The Hamiltonian formalism of one-dimensional systems of hydrodynamic type and the Bogolyubov - Whitham averaging method