/* multiset.c generated by valac 0.56.17, the Vala compiler
 * generated from multiset.vala, do not modify */

/* multiset.vala
 *
 * Copyright (C) 2009  Ali Sabil
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Ali Sabil <ali.sabil@gmail.com>
 */

#include "gee.h"
#include <glib-object.h>
#include <glib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GEE_TYPE_READ_ONLY_COLLECTION (gee_read_only_collection_get_type ())
#define GEE_READ_ONLY_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_READ_ONLY_COLLECTION, GeeReadOnlyCollection))
#define GEE_READ_ONLY_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_READ_ONLY_COLLECTION, GeeReadOnlyCollectionClass))
#define GEE_IS_READ_ONLY_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_READ_ONLY_COLLECTION))
#define GEE_IS_READ_ONLY_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_READ_ONLY_COLLECTION))
#define GEE_READ_ONLY_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_READ_ONLY_COLLECTION, GeeReadOnlyCollectionClass))

typedef struct _GeeReadOnlyCollection GeeReadOnlyCollection;
typedef struct _GeeReadOnlyCollectionClass GeeReadOnlyCollectionClass;

#define GEE_TYPE_READ_ONLY_MULTI_SET (gee_read_only_multi_set_get_type ())
#define GEE_READ_ONLY_MULTI_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_READ_ONLY_MULTI_SET, GeeReadOnlyMultiSet))
#define GEE_READ_ONLY_MULTI_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_READ_ONLY_MULTI_SET, GeeReadOnlyMultiSetClass))
#define GEE_IS_READ_ONLY_MULTI_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_READ_ONLY_MULTI_SET))
#define GEE_IS_READ_ONLY_MULTI_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_READ_ONLY_MULTI_SET))
#define GEE_READ_ONLY_MULTI_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_READ_ONLY_MULTI_SET, GeeReadOnlyMultiSetClass))

typedef struct _GeeReadOnlyMultiSet GeeReadOnlyMultiSet;
typedef struct _GeeReadOnlyMultiSetClass GeeReadOnlyMultiSetClass;

 G_GNUC_INTERNAL GeeReadOnlyMultiSet* gee_read_only_multi_set_new (GType g_type,
                                                  GBoxedCopyFunc g_dup_func,
                                                  GDestroyNotify g_destroy_func,
                                                  GeeMultiSet* multiset);
 G_GNUC_INTERNAL GeeReadOnlyMultiSet* gee_read_only_multi_set_construct (GType object_type,
                                                        GType g_type,
                                                        GBoxedCopyFunc g_dup_func,
                                                        GDestroyNotify g_destroy_func,
                                                        GeeMultiSet* multiset);
 G_GNUC_INTERNAL GType gee_read_only_collection_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
 G_GNUC_INTERNAL GType gee_read_only_multi_set_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static GType gee_multi_set_get_type_once (void);

/**
 * Returns the number of occurrences of an item in this multiset.
 *
 * @param item the item to count occurrences of
 *
 * @return     the number of occurrences of the item in this multiset.
 */
gint
gee_multi_set_count (GeeMultiSet* self,
                     gconstpointer item)
{
	GeeMultiSetIface* _iface_;
	g_return_val_if_fail (self != NULL, 0);
	_iface_ = GEE_MULTI_SET_GET_INTERFACE (self);
	if (_iface_->count) {
		return _iface_->count (self, item);
	}
	return -1;
}

/**
 * Returns an immutable empty set.
 *
 * @return an immutable empty set
 */
GeeSet*
gee_multi_set_empty (GType g_type,
                     GBoxedCopyFunc g_dup_func,
                     GDestroyNotify g_destroy_func)
{
	GeeHashSet* _tmp0_;
	GeeHashSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	GeeSet* _tmp4_;
	GeeSet* result;
	_tmp0_ = gee_hash_set_new (g_type, (GBoxedCopyFunc) g_dup_func, (GDestroyNotify) g_destroy_func, NULL, NULL, NULL, NULL, NULL, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = gee_abstract_set_get_read_only_view ((GeeAbstractSet*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp1_);
	result = _tmp4_;
	return result;
}

GeeMultiSet*
gee_multi_set_get_read_only_view (GeeMultiSet* self)
{
	GeeMultiSetIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GEE_MULTI_SET_GET_INTERFACE (self);
	if (_iface_->get_read_only_view) {
		return _iface_->get_read_only_view (self);
	}
	return NULL;
}

static GeeMultiSet*
gee_multi_set_real_get_read_only_view (GeeMultiSet* base)
{
	GeeMultiSet* result;
	GeeMultiSet* self;
	GeeReadOnlyMultiSet* _tmp0_;
	self = base;
	_tmp0_ = gee_read_only_multi_set_new (GEE_MULTI_SET_GET_INTERFACE (self)->get_g_type (self), (GBoxedCopyFunc) GEE_MULTI_SET_GET_INTERFACE (self)->get_g_dup_func (self), (GDestroyNotify) GEE_MULTI_SET_GET_INTERFACE (self)->get_g_destroy_func (self), self);
	result = (GeeMultiSet*) _tmp0_;
	return result;
}

static void
gee_multi_set_default_init (GeeMultiSetIface * iface,
                            gpointer iface_data)
{
	iface->get_read_only_view = gee_multi_set_real_get_read_only_view;
}

/**
 * A collection with duplicate elements.
 */
static GType
gee_multi_set_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GeeMultiSetIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gee_multi_set_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gee_multi_set_type_id;
	gee_multi_set_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeMultiSet", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gee_multi_set_type_id, GEE_TYPE_COLLECTION);
	return gee_multi_set_type_id;
}

GType
gee_multi_set_get_type (void)
{
	static volatile gsize gee_multi_set_type_id__once = 0;
	if (g_once_init_enter (&gee_multi_set_type_id__once)) {
		GType gee_multi_set_type_id;
		gee_multi_set_type_id = gee_multi_set_get_type_once ();
		g_once_init_leave (&gee_multi_set_type_id__once, gee_multi_set_type_id);
	}
	return gee_multi_set_type_id__once;
}

