Skip to main content

Adding Application Keys and Values

  • Chapter
  • First Online:
The Joys of Hashing
  • 1395 Accesses

Abstract

So far, you have only considered storing keys in your hash tables. Most of the techniques for implementing hash tables do not depend on whether you store simple keys or whether you associate application values with them. The setup where you only store keys that you can also use as hash keys, however, is practically never used in real-world applications. This chapter is about storing application values in bins together with their hash keys. You can download the code at https://github.com/mailund/JoyChapter5 .

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 44.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    This will fail if you try to map keys to null pointers; then you would need to add the contains operation as a separate function.

  2. 2.

    If you worry that the earlier implementations where you did use the contains function are inefficient, don’t. There, you would not update the link if it was already found in the list, and if it was not, you prepended a new link. You wouldn’t search through the linked list twice in those operations.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Thomas Mailund

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Mailund, T. (2019). Adding Application Keys and Values. In: The Joys of Hashing. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4066-3_5

Download citation

Publish with us

Policies and ethics