Re: Do PostgreSQL have map and set structure(like STL in C++)?

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: 梦旅人 <liubaozhu1258(at)qq(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Do PostgreSQL have map and set structure(like STL in C++)?
Date: 2019-04-21 17:22:34
Message-ID: FF3A6B25-AE3C-4936-A87D-C39966259E46@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Liu!

> 21 апр. 2019 г., в 17:32, 梦旅人 <liubaozhu1258(at)qq(dot)com> написал(а):
> I want to add a feature in PostgreSQL, and I need use map structure and set structure(like STL in C++). Do PostgreSQL have 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2019-04-21 18:31:15 [PATCH v1] Add \echo_stderr to psql
Previous Message Fabien COELHO 2019-04-21 17:22:20 Re: Do PostgreSQL have map and set structure(like STL in C++)?