ucx/cx/map.h

changeset 77
5de33c2d94c6
parent 49
2f71f4ee247a
equal deleted inserted replaced
76:641dcc79e0ef 77:5de33c2d94c6
631 const char *key 631 const char *key
632 ) { 632 ) {
633 (void) map->cl->remove(map, cx_hash_key_str(key), false); 633 (void) map->cl->remove(map, cx_hash_key_str(key), false);
634 } 634 }
635 635
636 /** 636
637 * Removes a key/value-pair from the map by using the key.
638 *
639 * This function can be used when the map is storing pointers,
640 * in order to retrieve the pointer from the map without invoking
641 * any destructor function. Sometimes you do not want the pointer
642 * to be returned - in that case (instead of suppressing the "unused
643 * result" warning) you can use cxMapDetach().
644 *
645 * If this map is not storing pointers, this function behaves like
646 * cxMapRemove() and returns \c NULL.
647 *
648 * @param map the map
649 * @param key the key
650 * @return the stored pointer or \c NULL if either the key is not present
651 * in the map or the map is not storing pointers
652 * @see cxMapStorePointers()
653 * @see cxMapDetach()
654 */
655 __attribute__((__nonnull__, __warn_unused_result__))
656 static inline void *cxMapRemoveAndGet(
657 CxMap *map,
658 CxHashKey key
659 ) {
660 return map->cl->remove(map, key, !map->store_pointer);
661 }
662
663 /**
664 * Removes a key/value-pair from the map by using the key.
665 *
666 * This function can be used when the map is storing pointers,
667 * in order to retrieve the pointer from the map without invoking
668 * any destructor function. Sometimes you do not want the pointer
669 * to be returned - in that case (instead of suppressing the "unused
670 * result" warning) you can use cxMapDetach().
671 *
672 * If this map is not storing pointers, this function behaves like
673 * cxMapRemove() and returns \c NULL.
674 *
675 * @param map the map
676 * @param key the key
677 * @return the stored pointer or \c NULL if either the key is not present
678 * in the map or the map is not storing pointers
679 * @see cxMapStorePointers()
680 * @see cxMapDetach()
681 */
682 __attribute__((__nonnull__, __warn_unused_result__))
683 static inline void *cxMapRemoveAndGet(
684 CxMap *map,
685 cxstring key
686 ) {
687 return map->cl->remove(map, cx_hash_key_cxstr(key), !map->store_pointer);
688 }
689
690 /**
691 * Removes a key/value-pair from the map by using the key.
692 *
693 * This function can be used when the map is storing pointers,
694 * in order to retrieve the pointer from the map without invoking
695 * any destructor function. Sometimes you do not want the pointer
696 * to be returned - in that case (instead of suppressing the "unused
697 * result" warning) you can use cxMapDetach().
698 *
699 * If this map is not storing pointers, this function behaves like
700 * cxMapRemove() and returns \c NULL.
701 *
702 * @param map the map
703 * @param key the key
704 * @return the stored pointer or \c NULL if either the key is not present
705 * in the map or the map is not storing pointers
706 * @see cxMapStorePointers()
707 * @see cxMapDetach()
708 */
709 __attribute__((__nonnull__, __warn_unused_result__))
710 static inline void *cxMapRemoveAndGet(
711 CxMap *map,
712 cxmutstr key
713 ) {
714 return map->cl->remove(map, cx_hash_key_cxstr(key), !map->store_pointer);
715 }
716
717 /**
718 * Removes a key/value-pair from the map by using the key.
719 *
720 * This function can be used when the map is storing pointers,
721 * in order to retrieve the pointer from the map without invoking
722 * any destructor function. Sometimes you do not want the pointer
723 * to be returned - in that case (instead of suppressing the "unused
724 * result" warning) you can use cxMapDetach().
725 *
726 * If this map is not storing pointers, this function behaves like
727 * cxMapRemove() and returns \c NULL.
728 *
729 * @param map the map
730 * @param key the key
731 * @return the stored pointer or \c NULL if either the key is not present
732 * in the map or the map is not storing pointers
733 * @see cxMapStorePointers()
734 * @see cxMapDetach()
735 */
736 __attribute__((__nonnull__, __warn_unused_result__))
737 static inline void *cxMapRemoveAndGet(
738 CxMap *map,
739 const char *key
740 ) {
741 return map->cl->remove(map, cx_hash_key_str(key), !map->store_pointer);
742 }
743 637
744 #else // __cplusplus 638 #else // __cplusplus
745 639
746 /** 640 /**
747 * Puts a key/value-pair into the map. 641 * Puts a key/value-pair into the map.

mercurial