123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /*!
- Temelia - Pair implementation source file.
- Copyright (C) 2008, 2009 Ceata (http://ceata.org/proiecte/temelia).
- @author Dascalu Laurentiu
- This program is free software; you can redistribute it and
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 3
- of the License, or (at your option) any later version.
- This program 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 General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
- #include "include/pair.h"
- #include "include/common.h"
- #include <stdlib.h>
- // Pair of key and value.
- struct _pair_t
- {
- /*! key */
- void *key;
- /*! value */
- void *value;
- };
- pair_t pair_new(void *key, void *value)
- {
- pair_t pair;
- pair = (struct _pair_t *) _new(sizeof(struct _pair_t));
- _ASSERT(pair, ==, NULL, NULL_POINTER, NULL);
- pair->key = key;
- pair->value = value;
- return pair;
- }
- void pair_delete(pair_t pair)
- {
- _ASSERT(pair, ==, NULL, NULL_POINTER,);
- pair->key = pair->value = NULL;
- _delete(pair);
- }
- void pair_set_key(pair_t pair, void *key)
- {
- _ASSERT(pair, ==, NULL, NULL_POINTER,);
- pair->key = key;
- }
- void pair_set_value(pair_t pair, void *value)
- {
- _ASSERT(pair, ==, NULL, NULL_POINTER,);
- pair->value = value;
- }
- void *pair_get_key(pair_t pair)
- {
- _ASSERT(pair, ==, NULL, NULL_POINTER, NULL);
- return pair->key;
- }
- void *pair_get_value(pair_t pair)
- {
- _ASSERT(pair, ==, NULL, NULL_POINTER, NULL);
- return pair->value;
- }
|