You are reading the article Examples To Implement Ansible Group_Vars updated in December 2023 on the website Katfastfood.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 Examples To Implement Ansible Group_Vars
Introduction to Ansible group_varsIn Ansible, we know that variables are very important as they store host-to-host data and usable to deploy some tasks based on remote host’s state-based. There are various ways to define variables like in the inventory file, in the playbook file, in a variable file imported in the playbook. Similarly, there is a way to define variables at a location from where the variables will be realized for a group of hosts. This location falls under group_vars and this can be under a predefined location. In this article, we will learn about group_vars with some examples and ways to use it.
Start Your Free Software Development Course
Web development, programming languages, Software testing & others
What is Ansible group_vars?It uses hosts file and group_vars directory to set variables for host groups and deploying Ansible plays/tasks against each host/group. Files under group_var directory are named after the host group’s name or all, accordingly, the variables will be assigned to that host group or all the hosts.
Although you can store the variables in inventory files and playbooks, having stored and defined variables in separate files and that too on a host group basis, adds simplicity and makes it easy to recognize, then use.
Files under group_vars are generically used to store basic identifying variables and then leverage these with other desirable variables by using include_vars and var_files.
How Does ANSIBLE group_vars work?Similarly, other combinations of these files are used, based on the host’s mapping to groups in the host’s file.
/etc/ansible/group_vars/grp1.yaml
/etc/ansible/group_vars/grp2.yml
/etc/ansible/group_vars/grp3
If there is file /etc/ansible/group_vars/all present then variables in this file will be pulled for every execution. The definition of variables in these files is simple key: value pair format. An example is like below:
Example
vegetable: potato
Also, there are a few points which should be noted when using group_vars:
We can create directories under the group named directory, it will read all the files under these directories in lexicographical
If there is some value which is true for your environment and for every server, the variable containing that value should be defined under /etc/ansible/group_vars/all file
In AWS case, when we have a dynamic inventory where host groups are created and removed automatically, we need to tag the EC2 instances like “class:webserver”. Then variables defined under the /etc/ansible/group_vars/ec2_tag_class_webserver will be located file.
If in hosts file, groups are organized in such an order that one group is a child of another, then the variables defined for children will have higher precedence over the variable with the same name defined for the parent
When the same host is defined for several groups on the same level of the parent-children hierarchy, the variable file precedence with being on the name of groups in alphabetic order. That means if a host is mapped under groups alpha, beta, and gamma. Then for this host variables under /etc/ansible/group_vars/gamma will be pulled.
We can use Ansible Vault for these files under group_vars, to protect the confidential data.
ExamplesNow by using examples, we will try to learn about Ansible group_vars, which you might have to use in day to day operations. We will take some examples, but before going there, we will first understand our lab, we will use for testing purpose.
Here it control server named ansible-controller and two remotes hosts named host- one and host-two. We will create playbooks and run commands on the ansible-controller node and see the results on remote hosts.
Also, group_vars directory is defined as /etc/ansible/group_vars. The inventory file is /etc/ansible/hosts.
We created three files named as below: –
/etc/ansible/group_vars/alpha
/etc/ansible/group_vars/beta
/etc/ansible/group_vars/gamma
The hosts file /etc/ansible/hosts have same groups named and the hosts mapping is like below
Example #1
[gamma] host-one host-two 127.0.0.1
In this example, we put contents like below under /etc/ansible/group_vars/alpha to define variables and other two files
/etc/ansible/group_vars/beta and
/etc/ansible/group_vars/gamma are empty.
Example #2
tomato
Now running debug module in ad-hoc command like below:
Example #3
We get the following output where we can see that only variable defined in the file /etc/ansible/group_vars/alpha for alpha group means the host-one host will be pulled.
In this example, we have a playbook with below
Example #4
content: “fruit variable valus is {{ fruit }}n” dest: /tmp/sample.ini
Also, group_vars directory is defined as /etc/ansible/group_vars and the files with content under this directory are listed as below:
cat /etc/ansible/group_vars/alpha
cat /etc/ansible/group_vars/beta
cat /etc/ansible/group_vars/gamma
When running playbook like below
Example #5
ansible-playbook ansible_group_vars.yaml
We get the following output where the variable value is copied to a file on the target host.
/etc/ansible/group_vars/gamma.
ssh host-one “cat /tmp/sample.ini”
In this example, we have a playbook with below content. Using this playbook, we try to print variables from various directories in a hierarchy under /etc/ansible/group_vars.
Example #6
msg: “Username is {{ username }} and connection port is {{ port }}”
Also, group_vars directory is defined as /etc/ansible/group_vars, which have files like below
ll /etc/ansible/group_vars/*/*
The files under this directory have content like below
cat /etc/ansible/group_vars/alpha/db_settings
cat /etc/ansible/group_vars/Charlie/connection_setting
When running playbook like below
ansible-playbook ansible_group_vars_dir.yaml
We get the following output where
ConclusionAs we can see in this article, using group_vars I easy to define and can be very helpful in cases where we need to work on a group of hosts. This not only saves our efforts to sort the hosts but also enhance the flexibility in our code. Also, the reusability of these group variables makes it more relevant to use in a production environment.
Recommended ArticlesThis is a guide to Ansible group_vars. Here we discuss an introduction to group_vars with syntax and respective examples to implement. You can also go through our other related articles to learn more –
You're reading Examples To Implement Ansible Group_Vars
Top 5 Examples To Implement Of Sql Timestamp
Introduction to SQL Timestamp
Timestamp is a data type and function in Standard Structured Query Language (SQL) that lets us store and work with both date and time data values, usually without specified time zones. The timestamp has a storage size of 8 bytes that can accept date and time values ranging from 4713 BC and 294276 AD and provides a resolution of 1 microsecond or 14 digits. Some SQL databases allow for customization of a timestamp data type where we can specify a timezone for the timestamp so that every time the database is used in a different timezone, it shows and accepts the corresponding date and time. For example, in PostgreSQL, we have a “timestamptz” data type that takes care of time zone changes as well. Timestamptz data type also has a storage size similar to a timestamp of 8 bytes that can accept date and time values ranging from 4713 BC and 294276 AD and provides a resolution of 1 microsecond or 14 digits.
Start Your Free Data Science Course
Hadoop, Data Science, Statistics & others
In this article, we will be learning the functions and differences of “timestamp” and “timestamptz” data types with the help of a few examples.
Syntax and Parameters:
The basic syntax of “timestamp” data type in SQL is as follows :
Timestamp 'date_expression time_expression';A valid timestamp data expression consists of a date and a time, followed by an optional BC or AD.
Timestamptz 'date_expression time_expression +/- time_zone_expression '; 2004-10-19 10:23:54; Examples to Implement of SQL TimestampBelow are a few examples to understand SQL Timestamp data type:
Note: For the purpose of this article, we have used the PostgreSQL server.
Example #1Getting to know important details of timestamp and timestamptz data type in SQL.
Code:
SELECT typname, typlen, typtype, typcategory FROM pg_type WHERE typname ~ '^timestamp';Output:
Example #2SQL query to illustrate the difference between timestamp and timestamptz data types.
Code:
SELECT TIMESTAMP '2023-03-23 00:00';Output:
SELECT TIMESTAMPTZ '2023-03-23 00:00';Output:
Example #3Some examples to show functions related to timestamp data type in SQL. First, let’s start by converting or casting a given date into a timestamp format, as shown below.
Code:
SELECT '2023-03-23' :: timestamptz;Output:
Suppose if we want to know the current timestamp, we can use the current_timestamp function as shown below. It will return the current timestamp, i.e. current date and time implicitly converted into the default timezone.
SELECT current_timestamp;Output:
Further, we can also check the timezone we are currently working in by using the SHOW timezone statement below. This becomes very helpful when you have operations all over the world.
SHOW timezone;Output:
Next, we can even change the current timezone to a different timezone using the SET timezone statement. Here, you may choose from a wide variety of timezones like ‘Asia/Kolkata’, ‘Europe/Zurich’, ‘US/Pacific’ etc. In this example, we have changed the timezone from ‘Asia/Kolkata’ to ‘US/Pacific’.
SET timezone = 'US/Pacific';A few functions like EXTRACT in SQL let us extract a specific piece of information from the timestamp. For example, we can extract DAY, MONTH, YEAR, HOUR, MINUTE, SECONDS, etc., from the timestamp.
In the following examples, we have tried to extract DAY and MONTH from the timestamp.
SELECT EXTRACT(DAY FROM '2023-03-23 00:00':: timestamp);Output:
SELECT EXTRACT(MONTH FROM '2023-03-23 00:00':: timestamp);Output:
Example #4SQL query to generate a series of timestamps in a specified timezone. In this example, we have generated a series of timestamps with a regular interval of 5 hours in two time zones, namely, ‘Indian Standard Time’ and ‘Pacific Standard Time. We can observe the difference between the two series by closely looking at the outputs.
Code:
SELECT generate_series( timezone('IST', '2023-03-23 00:00'::timestamp), timezone('IST', '2023-03-23 23:00'::timestamp), '5 hour'::interval );Output:
SELECT generate_series( timezone('PST', '2023-03-23 00:00'::timestamp), timezone('PST', '2023-03-23 23:00'::timestamp), '5 hour'::interval );Output:
Example #5A practical example to illustrate the use of timestamp or timestamptz data type in SQL. Let’s take an example of a business case, where a multinational bank wants to wish its customers “Happy Birthday” based on the customer’s local time. The bank’s database has a list of customers with their date of births. So the customers’ table can be created something like this :
Code:
CREATE TABLE Customers ( customer_id int, customer_name varchar(255), city varchar(255), date_of_birth timestamptz );Output:
After inserting the relevant information, the data in the table will look something like this:
Suppose we want to wish our customers in London who have their birthdays today i.e. ‘24th March 2023’ as per Indian Standard Time; we might be required to write a SQL query as shown below:
SELECT customer_name, date_of_birth FROM customers WHERE EXTRACT(DAY FROM date_of_birth) = '24' AND EXTRACT(MONTH FROM date_of_birth) = '03';Output:
SELECT customer_name, date_of_birth FROM customersOutput:
ConclusionSQL timestamp is a data type and function used to store and work with data values in date and time formats, sometimes along with time zones and AD/BCs. They are very helpful when we have operations all over the world.
Recommended ArticlesWe hope that this EDUCBA information on “SQL Timestamp” was beneficial to you. You can view EDUCBA’s recommended articles for more information.
Top 4 Examples To Implement Of Test() Function In C++
Introduction to C++ test() Function
Web development, programming languages, Software testing & others
bool test(int index) ;Parameters of C++ test() Function
Index: index is an int parameter that specifies the index position at which it is to test whether the bit is set or not. This is not an optional parameter.
The return value of this function is a boolean type, if the bit is set at the given index position then return true otherwise return false if the bit is not set.
Working of test() function in C++The test() function is used or call on the bitset sting(a collection of 0’s and 1’s stores in the string format) to find at a particular index position in a bit string whether the bit is set(1) or not set(0), so the test() function accepts only one parameter that is the index position of the bit string and checks for that index position in a bit string the bit is 1 or 0. If the bit store is 1 then returns true, else returns false if the bit is 0, as we can see in the below examples.
Examples to Implement test() Function in C++Below are the examples of test() function:
Example #1We write the C++ code to understand the test() function more clearly with the following example where we use test() function to check all the bit of the bit string, as below:
Code:
using namespace std; int main () { int i; for(i=0; i<6; i++) { cout << “The bit at index “<< i << ” is “<< bstr.test(i) << endl; } return 0; }
Output:
As in the above code the test() function is used to check all the bit with the help of for loop to get the index values. The index values 0 to 5 is passing to the test() function, so in each loop the particular index function is checking whether the bit is set that is one or not set that is zero. Therefore as in output, we can see that it is printing all the bits whether set or not from right to left.
Example #2We write the C++ code to understand the test() function where we use test() function to check the user given bit index of the bit string, as below:
using namespace std; int main () { int i, index; cout<<“Enter the bit index, which you want to test :”; cout << “The bit at given index “<< index << ” is “<< bstr.test(index) << endl; return 0; }
Output:
As in the above code the index position is accepted by the user and passed to the test() function to check only the given index bit is set or not set. As the user passed the index value 3 which is farther passed to the test() function, in the bit string (“010101”) we can see that at index 3 the bit is 0 which means not set. So in output we can see that it is printing the bit at given index is 0.
Example #3We write the C++ code to understand the test() function where we use test () function to check the user given bit index whether set or not, as below:
Code:
using namespace std; int main () { int index; cout<<“Enter the bit index, which you want to test :”; if(bstr.test(index)){ cout << “The bitset is set at index ” << index; } else { cout << “The bitset is not set at index ” << index; } return 0; }
Output:
As in the above code the index position is accepted by the user and passed the test() function. As the user passed the index value 3 which is farther passed to the test() function, as in the bit string (“010101”) we can see that at index 3 the bit is 0 which means not set, so the test() function return false and therefor in the output the false statement is printing.
Example #4We write the C++ code to understand the test() function where we use test() function to compare two different strings, as below:
Code:
using namespace std; int main () { int i; for( i=0; i<6; i++) { if(bstr1.test(i) == bstr2.test(i)){ continue; } else { break; } } if( i == 6 ) { cout<< “Both the bit strings are equal.”; } else { cout<< “Both the bit strings are not equal.”; } return 0; }
Output:
As in the above code the test() function is used to compare two bit strings, bit by bit. Here the both string bits are not same, so the output is printing that both bit strings are not equal.
Conclusion Recommended ArticlesThis is a guide to C++ test(). Here we discuss the brief overview of C++ test() Function and its working along with Examples and Code Implementation. You can also go through our other suggested articles to learn more –
C++ Program To Implement Merge Sort
The merge sort technique is based on divide and conquer technique. We divide the while data set into smaller parts and merge them into a larger piece in sorted order. It is also very effective for worst cases because this algorithm has lower time complexity for worst case also.
The complexity of Merge Sort Technique
Time Complexity: O(n log n) for all cases
Space Complexity: O(n)
Input − The unsorted list: 14 20 78 98 20 45 Output − Array after Sorting: 14 20 20 45 78 98 Algorithm merge(array, left, middle, right)Input: The data set array, left, middle and right index
Output: The merged list
Begin nLeft := m - left+1 nRight := right – m define arrays leftArr and rightArr of size nLeft and nRight respectively for i := 0 to nLeft do leftArr[i] := array[left +1] done for j := 0 to nRight do rightArr[j] := array[middle + j +1] done i := 0, j := 0, k := left while i < nLeft AND j < nRight do if leftArr[i] <= rightArr[j] then array[k] = leftArr[i] i := i+1 else array[k] = rightArr[j] j := j+1 k := k+1 done while i < nLeft do array[k] := leftArr[i] i := i+1 k := k+1 done while j < nRight do array[k] := rightArr[j] j := j+1 k := k+1 done End mergeSort(array, left, right)Input: An array of data, and lower and upper bound of the array
Output: The sorted Array
Begin if lower < right then mid := left + (right - left) /2 mergeSort(array, left, mid) mergeSort (array, mid+1, right) merge(array, left, mid, right) using namespace std; void swapping(int &a, int &b) { int temp; temp = a; a = b; b = temp; } void display(int *array, int size) { for(int i = 0; i<size; i++) cout << array[i] << " "; cout << endl; } void merge(int *array, int l, int m, int r) { int i, j, k, nl, nr; //size of left and right sub-arrays nl = m-l+1; nr = r-m; int larr[nl], rarr[nr]; //fill left and right sub-arrays for(i = 0; i<nl; i++) larr[i] = array[l+i]; for(j = 0; j<nr; j++) rarr[j] = array[m+1+j]; i = 0; j = 0; k = l; //marge temp arrays to real array while(i < nl && j<nr) { if(larr[i] <= rarr[j]) { array[k] = larr[i]; i++; }else{ array[k] = rarr[j]; j++; } k++; } while(i<nl) { array[k] = larr[i]; i++; k++; } while(j<nr) { array[k] = rarr[j]; j++; k++; } } void mergeSort(int *array, int l, int r) { int m; if(l < r) { int m = l+(r-l)/2; mergeSort(array, l, m); mergeSort(array, m+1, r); merge(array, l, m, r); } } int main() { int n; cout << "Enter the number of elements: "; int arr[n]; cout << "Enter elements:" << endl; for(int i = 0; i<n; i++) { } cout << "Array before Sorting: "; display(arr, n); mergeSort(arr, 0, n-1); cout << "Array after Sorting: "; display(arr, n); } Output Enter the number of elements: 6 Enter elements: 14 20 78 98 20 45 Array before Sorting: 14 20 78 98 20 45 Array after Sorting: 14 20 20 45 78 98Working And Different List Of Plugins In Ansible
Introduction to Ansible Plugins
Ansible plugins are separately available functions which are used to work with Ansible modules. These are the codes developed to provide additional support to Ansible modules while working on remote target hosts. Though the Ansible package comes with many plugins, we can also write our custom plugins. In Ansible, plugins are prepared in an architecture that adds more flexibility and expandability to the feature set. Most importantly, plugins are different from modules and run only locally on the Ansible controller node within the Ansible process. In addition, plugins provide additional options and extensions to the core functionality of Ansible, like output logging, inventory connection, data transformation.
Start Your Free Software Development Course
Web development, programming languages, Software testing & others
Working of Ansible PluginsAnsible plugins work locally on the Ansible controller node, which means some data is given to a plugin, and the plugin processes that data. Modules use this processed data to perform some tasks on remote target machines. This might look easy, but one can easily get puzzled while choosing or using plugins, as the syntax is not in YAML of JSON. Plugins follow a unique syntax which is different for different plugins.
To confirm your plugin is working or loading. You can use ansible-doc to check the plugin, run the command like below:
Ansible package is shipped with a range of plugins, including Action, Callback, Cache, Become, Connection, Inventory, Lookup, Shell, Vars, Filters, Test. Also, you can add your customized plugins by writing the incompatible version of Python, and code should have error reporting, return strings in Unicode, and line with Ansible documentation and configuration standards. In the next section, we will learn about some of the default plugins types with examples.
List of Ansible PluginsBelow is a list of plugins types provided by Ansible packages, but you must note that this list if not exhaustive and can be extended in future releases or updated in the current release. In addition, these plugin types further have plugins that can use in our playbooks. For the latest list of plugin types, you can refer below the official Ansible community page.
To get a list of available plugin’s list of a plugin type, you can use the below command:
Also, for practical purposes, here we have an Ansible control server named ansible-controller and two remotes hosts named host-one and host-two. We will create playbooks, run Ansible commands on the ansible-controller node, and see the results on remote hosts. The way of use in these examples is completely to show you how to use these, but your real-life usage/requirements may be different from these.
1. ActionThese plugins work on the front end and are executed in the local controller node before calling any module. These plugins are associated with some modules and are executed by default when such modules are used. Therefore, you cannot list action plugins.
2. BecomeThese plugins are enabled by default, and these are used to ensure that Ansible can use certain privileges on remote machines while running such commands, which need higher privileges. Plugin list includes sudo, su, doas, runas. These plugins are used along with become_methodkeyword in a playbook. For example, we have a playbook with content like below, here we are running this playbook with the root user, but as we mentioned becomes parameters in the playbook. We are trying to run the command as ec2-user. In the output, we will see that command ran as ec2-user.
Please note, this user must exist on the target machine, else the playbook will fail.
var: id_var[‘stdout_lines’]
ansible-playbook ansible_sudo.yaml
We get the output like below:
3. LookupThese plugins are used to fetch data from an external source. This uses Jinja2. One of the important plugins is the file which is used to read the contents of a file. For example, we will take contents from a local file on the Ansible control machine and display its output using a plugin file which is a lookup plugin type. For this, we create a playbook, like below:
msg: These are the contents of /tmp/samplefile – {{lookup(‘file’, ‘/tmp/samplefile’)}}
Code:
ansible-playbook ansible_lookup_file.yaml
We get output like below:
4. VarsThese plugins provided additional data to Ansible plays which inventory, playbook, and parameters provided on the command line did not provide. These plugins are automatically enabled and used with keywords like host_vars and group_vars.
5. CacheThese plugins are used to store a cache of Ansible facts so that we do not have to gather those, again and again; this can be helpful in cost-saving where I/O is measured and incur costs.
6. FiltersThese allow you to filter data within the controller node and provide it to playbooks and templates. This uses Jinja2. In this type, the variety of plugins is vast also; there are some mathematics-related plugins like abs, int, pow, root. To check some of these, we can make a playbook with content like below: –
msg: Fifth power of -2.5 is “{{ var_pow }}”
Code:
ansible-playbook filter_math.yaml
The output will be like below:
ConclusionAs we saw in this article, Ansible plugins can perform a vital part in Ansible playbooks, especially when we have needs like data transformation, filtering, etc. You must have good knowledge of using the plugins if you have multiple environments and your needs are to process data locally on the controller node. So learn it first and then use it.
Recommended ArticlesThis is a guide to Ansible Plugins. Here we discuss the Working and the list of plugins types provided by Ansible packages. You may also have a look at the following articles to learn more –
C++ Program To Implement Hash Tables With Linear Probing
A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.
Linear probing is a collision resolving technique in Open Addressed Hash tables. In this method, each cell of a hash table stores a single key–value pair. If a collision is occurred by mapping a new key to a cell of the hash table that is already occupied by another key. This method searches the table for the following closest free location and inserts the new key there.
This is a C++ Program to Implement Hash Tables with Linear Probing.
AlgorithmFor Insert:
Begin Declare Function Insert(int k, int v) int hash_val = HashFunc(k) intialize init = -1 intialize delindex = -1 while (hash_val != init and (ht[hash_val]==DelNode::getNode() or ht[hash_val] if (init == -1) init = hash_val if (ht[hash_val] == DelNode::getNode()) delindex = hash_val hash_val = HashFunc(hash_val + 1) if(delindex != -1) ht[delindex] = new HashTable(k, v) else ht[hash_val] = new HashTable(k, v) if(init != hash_val) if (ht[hash_val] != DelNode::getNode()) if (ht[hash_val] != NULL) else ht[hash_val] = new HashTable(k, v) End.For Search a key:
Begin Declare Function SearchKey(int k) int hash_val = HashFunc(k) int init = -1 while (hash_val != init and (ht[hash_val] == DelNode::getNode() or ht[hash_val] if (init == -1) init = hash_val hash_val = HashFunc(hash_val + 1) if (ht[hash_val] == NULL or hash_val == init) return -1 else End.For Delete:
Begin Declare Function Remove(int k) int hash_val = HashFunc(k) intialize init = -1 while (hash_val != init and (ht[hash_val] == DelNode::getNode() or ht[hash_val] if (init == -1) init = hash_val hash_val = HashFunc(hash_val + 1) if (hash_val != init && ht[hash_val] != NULL) delete ht[hash_val] ht[hash_val] = DelNode::getNode() using namespace std; const int T_S = 5; class HashTable { public: int k; int v; HashTable(int k, int v) { } }; class DelNode:public HashTable { private: static DelNode *en; DelNode():HashTable(-1, -1) {} public: static DelNode *getNode() { if (en == NULL) en = new DelNode(); return en; } }; DelNode *DelNode::en = NULL; class HashMapTable { private: HashTable **ht; public: HashMapTable() { ht = new HashTable* [T_S]; for (int i = 0; i < T_S; i++) { ht[i] = NULL; } } int HashFunc(int k) { return k % T_S; } void Insert(int k, int v) { int hash_val = HashFunc(k); int init = -1; int delindex = -1; if (init == -1) init = hash_val; if (ht[hash_val] == DelNode::getNode()) delindex = hash_val; hash_val = HashFunc(hash_val + 1); } if(delindex != -1) ht[delindex] = new HashTable(k, v); else ht[hash_val] = new HashTable(k, v); } if(init != hash_val) { if (ht[hash_val] != DelNode::getNode()) { if (ht[hash_val] != NULL) { } } else ht[hash_val] = new HashTable(k, v); } } int SearchKey(int k) { int hash_val = HashFunc(k); int init = -1; if (init == -1) init = hash_val; hash_val = HashFunc(hash_val + 1); } return -1; else } void Remove(int k) { int hash_val = HashFunc(k); int init = -1; if (init == -1) init = hash_val; hash_val = HashFunc(hash_val + 1); } if (hash_val != init && ht[hash_val] != NULL) { delete ht[hash_val]; ht[hash_val] = DelNode::getNode(); } } ~HashMapTable() { delete[] ht; } }; int main() { HashMapTable hash; int k, v; int c; while(1) { cout<<"1.Insert element into the table"<<endl; cout<<"2.Search element from the key"<<endl; cout<<"3.Delete element at a key"<<endl; cout<<"4.Exit"<<endl; cout<<"Enter your choice: "; switch(c) { case 1: cout<<"Enter element to be inserted: "; cout<<"Enter key at which element to be inserted: "; hash.Insert(k, v); break; case 2: cout<<"Enter key of the element to be searched: "; if(hash.SearchKey(k) == -1) { cout<<"No element found at key "<<k<<endl; continue; } else { cout<<"Element at key "<<k<<" : "; cout<<hash.SearchKey(k)<<endl; } break; case 3: cout<<"Enter key of the element to be deleted: "; hash.Remove(k); break; case 4: exit(1); default: cout<<"nEnter correct optionn"; } } return 0; } Output 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 1 Enter element to be inserted: 10 Enter key at which element to be inserted: 2 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 1 Enter element to be inserted: 7 Enter key at which element to be inserted: 6 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 1 Enter element to be inserted: 4 Enter key at which element to be inserted: 5 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 1 Enter element to be inserted: 12 Enter key at which element to be inserted: 3 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 15 Enter correct option 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 1 Enter element to be inserted: 15 Enter key at which element to be inserted: 8 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 2 Enter key of the element to be searched: 6 Element at key 6 : 7 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 3 Enter key of the element to be deleted: 2 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 2 Enter key of the element to be searched: 2 No element found at key 2 1.Insert element into the table 2.Search element from the key 3.Delete element at a key 4.Exit Enter your choice: 4Update the detailed information about Examples To Implement Ansible Group_Vars on the Katfastfood.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!