Re: Do PostgreSQL have map and set structure(like STL in C++)? - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: Do PostgreSQL have map and set structure(like STL in C++)?
Date
Msg-id FF3A6B25-AE3C-4936-A87D-C39966259E46@yandex-team.ru
Whole thread Raw
In response to Do PostgreSQL have map and set structure(like STL in C++)?  ("梦旅人" <liubaozhu1258@qq.com>)
Responses Re: Do PostgreSQL have map and set structure(like STL in C++)?
List pgsql-hackers
Hello Liu!

> 21 апр. 2019 г., в 17:32, 梦旅人 <liubaozhu1258@qq.com> написал(а):
>    I want to add a feature in PostgreSQL, and I need use map structure and set structure(like STL in C++). Do
PostgreSQLhave realized these structures? Where can I find the functions? 
>     What I need in the code is just like this:
>     map<char*, set<char*> >
>     set<char*>

You can use HTAB at utils/hsearch.h [0]

It is Larson's dynamic hashing, implementation is in backend/utils/hash/dynahash.c
Mostly like unordered_map. Accordingly, it lacks lower bound functionality as sorted sets do.

Also, you can user RB-tree in lib/rbtree.h [1] It's usual red-black tree.

Best regards, Andrey Borodin.


[0] https://github.com/postgres/postgres/blob/master/src/include/utils/hsearch.h
[1] https://github.com/postgres/postgres/blob/master/src/include/lib/rbtree.h


pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: Do PostgreSQL have map and set structure(like STL in C++)?
Next
From: David Fetter
Date:
Subject: [PATCH v1] Add \echo_stderr to psql