-sg_host_t sg_host_by_name_or_create(const char *name) {
- sg_host_t res = xbt_lib_get_elm_or_null(host_lib, name);
- if (!res) {
- xbt_lib_set(host_lib,name,0,NULL); // Should only create the bucklet with no data added
- res = xbt_lib_get_elm_or_null(host_lib, name);
- }
- return res;
+size_t sg_host_count()
+{
+ return xbt_dict_length(host_list);
+}
+/** @brief Returns the host list
+ *
+ * Uses sg_host_count() to know the array size.
+ *
+ * \return an array of \ref sg_host_t containing all the hosts in the platform.
+ * \remark The host order in this array is generally different from the
+ * creation/declaration order in the XML platform (we use a hash table
+ * internally).
+ * \see sg_host_count()
+ */
+sg_host_t *sg_host_list() {
+ xbt_assert(sg_host_count() > 0, "There is no host!");
+ return (sg_host_t*)xbt_dynar_to_array(sg_hosts_as_dynar());